diff options
| author | kadmin <julianknodt@gmail.com> | 2020-08-26 00:30:02 +0000 |
|---|---|---|
| committer | kadmin <julianknodt@gmail.com> | 2020-08-30 19:39:51 +0000 |
| commit | 8894b366fdb976a703fe76010f6e56c591cada1f (patch) | |
| tree | 3a4df5c9914a364aa388b9f4ccf16e65726acf4b | |
| parent | 85fbf49ce0e2274d0acf798f6e703747674feec3 (diff) | |
| download | rust-8894b366fdb976a703fe76010f6e56c591cada1f.tar.gz rust-8894b366fdb976a703fe76010f6e56c591cada1f.zip | |
Remove error message in specific case
In the case that a trait is not implemented for an ADT with type errors, cancel the error.
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/traits/issue-75627.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/traits/issue-75627.stderr | 9 |
3 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 138293c9533..f86fc425bd3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1906,6 +1906,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { ObligationCauseCode::BuiltinDerivedObligation(ref data) => { let parent_trait_ref = self.resolve_vars_if_possible(&data.parent_trait_ref); let ty = parent_trait_ref.skip_binder().self_ty(); + if parent_trait_ref.references_error() { + err.cancel(); + return; + } + err.note(&format!("required because it appears within the type `{}`", ty)); obligated_types.push(ty); diff --git a/src/test/ui/traits/issue-75627.rs b/src/test/ui/traits/issue-75627.rs new file mode 100644 index 00000000000..93a2ec1cc50 --- /dev/null +++ b/src/test/ui/traits/issue-75627.rs @@ -0,0 +1,6 @@ +struct Foo<T>(T, *const ()); + +unsafe impl Send for Foo<T> {} +//~^ ERROR cannot find type + +fn main() {} diff --git a/src/test/ui/traits/issue-75627.stderr b/src/test/ui/traits/issue-75627.stderr new file mode 100644 index 00000000000..92d9ac0f84c --- /dev/null +++ b/src/test/ui/traits/issue-75627.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `T` in this scope + --> $DIR/issue-75627.rs:3:26 + | +LL | unsafe impl Send for Foo<T> {} + | ^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. |
