diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-06-05 23:48:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-05 23:48:00 +0200 |
| commit | dcdd867a5298b5e5aedb77dc6b38862aa1867a44 (patch) | |
| tree | 28cb59f8eb34377dd89c11c51c1a8b39e4744123 | |
| parent | 44acf796c7e7ce441c8d7d7a34877554aeecdf27 (diff) | |
| parent | 0e9e91a95ace9f23e5371bd97e54fe4567150058 (diff) | |
| download | rust-dcdd867a5298b5e5aedb77dc6b38862aa1867a44.tar.gz rust-dcdd867a5298b5e5aedb77dc6b38862aa1867a44.zip | |
Rollup merge of #112322 - compiler-errors:no-IMPLIED_BOUNDS_ENTAILMENT-if-errs, r=eholk
Don't mention `IMPLIED_BOUNDS_ENTAILMENT` if signatures reference error Fixes #112321
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/compare_impl_item.rs | 2 | ||||
| -rw-r--r-- | tests/ui/implied-bounds/references-err.rs | 22 | ||||
| -rw-r--r-- | tests/ui/implied-bounds/references-err.stderr | 9 |
3 files changed, 32 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index d95862420da..dce31975dbc 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -302,7 +302,7 @@ fn compare_method_predicate_entailment<'tcx>( return Err(emitted); } - if check_implied_wf == CheckImpliedWfMode::Check { + if check_implied_wf == CheckImpliedWfMode::Check && !(impl_sig, trait_sig).references_error() { // We need to check that the impl's args are well-formed given // the hybrid param-env (impl + trait method where-clauses). ocx.register_obligation(traits::Obligation::new( diff --git a/tests/ui/implied-bounds/references-err.rs b/tests/ui/implied-bounds/references-err.rs new file mode 100644 index 00000000000..203d512e398 --- /dev/null +++ b/tests/ui/implied-bounds/references-err.rs @@ -0,0 +1,22 @@ +trait Identity { + type Identity; +} +impl<T> Identity for T { + type Identity = T; +} + +trait Trait { + type Assoc: Identity; + fn tokenize(&self) -> <Self::Assoc as Identity>::Identity; +} + +impl Trait for () { + type Assoc = DoesNotExist; + //~^ ERROR cannot find type `DoesNotExist` in this scope + + fn tokenize(&self) -> <Self::Assoc as Identity>::Identity { + unimplemented!() + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/references-err.stderr b/tests/ui/implied-bounds/references-err.stderr new file mode 100644 index 00000000000..6076eea3c75 --- /dev/null +++ b/tests/ui/implied-bounds/references-err.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `DoesNotExist` in this scope + --> $DIR/references-err.rs:14:18 + | +LL | type Assoc = DoesNotExist; + | ^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. |
