Skip to content

Commit 8894b36

Browse files
committed
Remove error message in specific case
In the case that a trait is not implemented for an ADT with type errors, cancel the error.
1 parent 85fbf49 commit 8894b36

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
@@ -1906,6 +1906,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
19061906
ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
19071907
let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref);
19081908
let ty = parent_trait_ref.skip_binder().self_ty();
1909+
if parent_trait_ref.references_error() {
1910+
err.cancel();
1911+
return;
1912+
}
1913+
19091914
err.note(&format!("required because it appears within the type `{}`", ty));
19101915
obligated_types.push(ty);
19111916

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)