Skip to content

Commit 93c6c04

Browse files
Restore error messaging
1 parent 9d4f1d8 commit 93c6c04

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

compiler/rustc_hir_typeck/src/method/probe.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,17 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14651465
ocx.register_obligation(obligation);
14661466
} else {
14671467
result = ProbeResult::NoMatch;
1468+
if let Ok(Some(candidate)) = self.select_trait_candidate(trait_ref) {
1469+
for nested_obligation in candidate.nested_obligations() {
1470+
if !self.infcx.predicate_may_hold(&nested_obligation) {
1471+
possibly_unsatisfied_predicates.push((
1472+
self.resolve_vars_if_possible(nested_obligation.predicate),
1473+
Some(self.resolve_vars_if_possible(obligation.predicate)),
1474+
Some(nested_obligation.cause),
1475+
));
1476+
}
1477+
}
1478+
}
14681479
}
14691480

14701481
trait_predicate = Some(ty::Binder::dummy(trait_ref).to_predicate(self.tcx));

tests/ui/mismatched_types/issue-36053-2.stderr

+4-6
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ error[E0599]: the method `count` exists for struct `Filter<Fuse<Once<&str>>, {cl
2121
LL | once::<&str>("str").fuse().filter(|a: &str| true).count();
2222
| --------- ^^^^^ method cannot be called due to unsatisfied trait bounds
2323
| |
24-
| doesn't satisfy `_: FnMut<(&&str,)>` or `_: FnOnce<(&&str,)>`
24+
| doesn't satisfy `<_ as FnOnce<(&&str,)>>::Output = bool` or `_: FnMut<(&&str,)>`
2525
|
2626
= note: the following trait bounds were not satisfied:
27-
`{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnMut<(&&str,)>`
28-
which is required by `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator`
29-
`{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnOnce<(&&str,)>`
27+
`<{closure@$DIR/issue-36053-2.rs:7:39: 7:48} as FnOnce<(&&str,)>>::Output = bool`
3028
which is required by `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator`
3129
`{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnMut<(&&str,)>`
32-
which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator`
33-
`{closure@$DIR/issue-36053-2.rs:7:39: 7:48}: FnOnce<(&&str,)>`
30+
which is required by `Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator`
31+
`Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator`
3432
which is required by `&mut Filter<Fuse<std::iter::Once<&str>>, {closure@$DIR/issue-36053-2.rs:7:39: 7:48}>: Iterator`
3533

3634
error: aborting due to 2 previous errors

tests/ui/traits/method-on-unbounded-type-param.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ LL | x.cmp(&x);
7070
which is required by `Box<dyn T>: Iterator`
7171
`dyn T: Ord`
7272
which is required by `Box<dyn T>: Ord`
73-
`dyn T: Iterator`
73+
`Box<dyn T>: Iterator`
7474
which is required by `&mut Box<dyn T>: Iterator`
7575
`dyn T: Iterator`
7676
which is required by `&mut dyn T: Iterator`

tests/ui/typeck/issue-31173.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ LL | | .collect();
3939
= note: the following trait bounds were not satisfied:
4040
`<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}> as Iterator>::Item = &_`
4141
which is required by `Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator`
42-
`<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}> as Iterator>::Item = &_`
42+
`Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator`
4343
which is required by `&mut Cloned<TakeWhile<&mut std::vec::IntoIter<u8>, {closure@$DIR/issue-31173.rs:7:21: 7:25}>>: Iterator`
4444

4545
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)