Skip to content

Commit 5fa978f

Browse files
authored
Rollup merge of #75928 - JulianKnodt:non_utf8, r=estebank
Remove trait_selection error message in specific case In the case that a trait is not implemented for an ADT with type errors, cancel the error. Fixes #75627
2 parents 6c9e857 + 8894b36 commit 5fa978f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19071907
ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
19081908
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
19091909
let ty = parent_trait_ref.skip_binder().self_ty();
1910+
if parent_trait_ref.references_error() {
1911+
err.cancel();
1912+
return;
1913+
}
1914+
19101915
err.note(&format!("required because it appears within the type `{}`", ty));
19111916
obligated_types.push(ty);
19121917

src/test/ui/traits/issue-75627.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
struct Foo<T>(T, *const ());
2+
3+
unsafe impl Send for Foo<T> {}
4+
//~^ ERROR cannot find type
5+
6+
fn main() {}

src/test/ui/traits/issue-75627.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `T` in this scope
2+
--> $DIR/issue-75627.rs:3:26
3+
|
4+
LL | unsafe impl Send for Foo<T> {}
5+
| ^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)