Skip to content

Commit 2eb7d69

Browse files
Resolve vars when reporting WF error
1 parent f12695b commit 2eb7d69

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
10491049
}
10501050

10511051
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty)) => {
1052+
let ty = self.resolve_vars_if_possible(ty);
10521053
match self.tcx.sess.opts.unstable_opts.trait_solver {
10531054
TraitSolver::Classic => {
10541055
// WF predicates cannot themselves make

tests/ui/for/issue-20605.next.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | for item in *things { *item = 0 }
1414
= note: all local variables must have a statically known size
1515
= help: unsized locals are gated as an unstable feature
1616

17-
error: the type `<_ as IntoIterator>::IntoIter` is not well-formed
17+
error: the type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed
1818
--> $DIR/issue-20605.rs:5:17
1919
|
2020
LL | for item in *things { *item = 0 }

tests/ui/for/issue-20605.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) {
55
for item in *things { *item = 0 }
66
//~^ ERROR the size for values of type
7-
//[next]~^^ ERROR the type `<_ as IntoIterator>::IntoIter` is not well-formed
7+
//[next]~^^ ERROR the type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed
88
//[next]~| ERROR the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
99
}
1010

tests/ui/traits/new-solver/alias-bound-unsound.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323
drop(<() as Foo>::copy_me(&x));
2424
//~^ ERROR `<() as Foo>::Item: Copy` is not satisfied
2525
//~| ERROR `<() as Foo>::Item` is not well-formed
26-
//~| ERROR `_` is not well-formed
27-
//~| ERROR `_` is not well-formed
26+
//~| ERROR `<() as Foo>::Item` is not well-formed
27+
//~| ERROR `<() as Foo>::Item` is not well-formed
2828
println!("{x}");
2929
}

tests/ui/traits/new-solver/alias-bound-unsound.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ error: the type `<() as Foo>::Item` is not well-formed
1919
LL | drop(<() as Foo>::copy_me(&x));
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^
2121

22-
error: the type `_` is not well-formed
22+
error: the type `<() as Foo>::Item` is not well-formed
2323
--> $DIR/alias-bound-unsound.rs:23:5
2424
|
2525
LL | drop(<() as Foo>::copy_me(&x));
2626
| ^^^^
2727

28-
error: the type `_` is not well-formed
28+
error: the type `<() as Foo>::Item` is not well-formed
2929
--> $DIR/alias-bound-unsound.rs:23:10
3030
|
3131
LL | drop(<() as Foo>::copy_me(&x));

0 commit comments

Comments
 (0)