diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-26 13:35:13 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-04-21 20:10:12 -0400 |
| commit | 93c6c0445db7f33d3fd85edbfb64768a88cef5ba (patch) | |
| tree | 0579e7060aa75967e25c23072f7d1e3164e6eb87 | |
| parent | 9d4f1d8b7eb3ac14dd1e3ba4f286a5db2c4232c5 (diff) | |
| download | rust-93c6c0445db7f33d3fd85edbfb64768a88cef5ba.tar.gz rust-93c6c0445db7f33d3fd85edbfb64768a88cef5ba.zip | |
Restore error messaging
| -rw-r--r-- | compiler/rustc_hir_typeck/src/method/probe.rs | 11 | ||||
| -rw-r--r-- | tests/ui/mismatched_types/issue-36053-2.stderr | 10 | ||||
| -rw-r--r-- | tests/ui/traits/method-on-unbounded-type-param.stderr | 2 | ||||
| -rw-r--r-- | tests/ui/typeck/issue-31173.stderr | 2 |
4 files changed, 17 insertions, 8 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 1dcda06a349..cfeb0792d9f 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1465,6 +1465,17 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { ocx.register_obligation(obligation); } else { result = ProbeResult::NoMatch; + if let Ok(Some(candidate)) = self.select_trait_candidate(trait_ref) { + for nested_obligation in candidate.nested_obligations() { + if !self.infcx.predicate_may_hold(&nested_obligation) { + possibly_unsatisfied_predicates.push(( + self.resolve_vars_if_possible(nested_obligation.predicate), + Some(self.resolve_vars_if_possible(obligation.predicate)), + Some(nested_obligation.cause), + )); + } + } + } } trait_predicate = Some(ty::Binder::dummy(trait_ref).to_predicate(self.tcx)); diff --git a/tests/ui/mismatched_types/issue-36053-2.stderr b/tests/ui/mismatched_types/issue-36053-2.stderr index 5b8332016de..ffaa276b62e 100644 --- a/tests/ui/mismatched_types/issue-36053-2.stderr +++ b/tests/ui/mismatched_types/issue-36053-2.stderr @@ -21,16 +21,14 @@ error[E0599]: the method `count` exists for struct `Filter<Fuse<Once<&str>>, {cl LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); | --------- ^^^^^ method cannot be called due to unsatisfied trait bounds | | - | doesn't satisfy `_: FnMut<(&&str,)>` or `_: FnOnce<(&&str,)>` + | doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool` or `_: FnMut<(&&str,)>` | = note: the following trait bounds were not satisfied: - `{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnMut<(&&str,)>` - which is required by `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` - `{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnOnce<(&&str,)>` + `<{closure@$DIR/issue-36053-2.rs:7:39: 7:48} as FnOnce<(&&str,)>>::Output = bool` which is required by `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` `{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnMut<(&&str,)>` - which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` - `{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnOnce<(&&str,)>` + which is required by `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` + `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/method-on-unbounded-type-param.stderr b/tests/ui/traits/method-on-unbounded-type-param.stderr index 38537619365..4d968e7bee1 100644 --- a/tests/ui/traits/method-on-unbounded-type-param.stderr +++ b/tests/ui/traits/method-on-unbounded-type-param.stderr @@ -70,7 +70,7 @@ LL | x.cmp(&x); which is required by `Box<dyn T>: Iterator` `dyn T: Ord` which is required by `Box<dyn T>: Ord` - `dyn T: Iterator` + `Box<dyn T>: Iterator` which is required by `&mut Box<dyn T>: Iterator` `dyn T: Iterator` which is required by `&mut dyn T: Iterator` diff --git a/tests/ui/typeck/issue-31173.stderr b/tests/ui/typeck/issue-31173.stderr index 5fee16b5e89..0983147a5f0 100644 --- a/tests/ui/typeck/issue-31173.stderr +++ b/tests/ui/typeck/issue-31173.stderr @@ -39,7 +39,7 @@ LL | | .collect(); = note: the following trait bounds were not satisfied: `<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}> as Iterator>::Item = &_` which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator` - `<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}> as Iterator>::Item = &_` + `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator` which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator` error: aborting due to 2 previous errors |
