Resolve vars when reporting WF error

This commit is contained in:
Michael Goulet 2023-06-23 16:26:22 +00:00
parent f12695b53b
commit 2eb7d69309
5 changed files with 7 additions and 6 deletions

View File

@ -1049,6 +1049,7 @@ fn report_selection_error(
} }
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty)) => { ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(ty)) => {
let ty = self.resolve_vars_if_possible(ty);
match self.tcx.sess.opts.unstable_opts.trait_solver { match self.tcx.sess.opts.unstable_opts.trait_solver {
TraitSolver::Classic => { TraitSolver::Classic => {
// WF predicates cannot themselves make // WF predicates cannot themselves make

View File

@ -14,7 +14,7 @@ LL | for item in *things { *item = 0 }
= note: all local variables must have a statically known size = note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature = help: unsized locals are gated as an unstable feature
error: the type `<_ as IntoIterator>::IntoIter` is not well-formed error: the type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed
--> $DIR/issue-20605.rs:5:17 --> $DIR/issue-20605.rs:5:17
| |
LL | for item in *things { *item = 0 } LL | for item in *things { *item = 0 }

View File

@ -4,7 +4,7 @@
fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) { fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) {
for item in *things { *item = 0 } for item in *things { *item = 0 }
//~^ ERROR the size for values of type //~^ ERROR the size for values of type
//[next]~^^ ERROR the type `<_ as IntoIterator>::IntoIter` is not well-formed //[next]~^^ ERROR the type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed
//[next]~| ERROR the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied //[next]~| ERROR the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
} }

View File

@ -23,7 +23,7 @@ fn main() {
drop(<() as Foo>::copy_me(&x)); drop(<() as Foo>::copy_me(&x));
//~^ ERROR `<() as Foo>::Item: Copy` is not satisfied //~^ ERROR `<() as Foo>::Item: Copy` is not satisfied
//~| ERROR `<() as Foo>::Item` is not well-formed //~| ERROR `<() as Foo>::Item` is not well-formed
//~| ERROR `_` is not well-formed //~| ERROR `<() as Foo>::Item` is not well-formed
//~| ERROR `_` is not well-formed //~| ERROR `<() as Foo>::Item` is not well-formed
println!("{x}"); println!("{x}");
} }

View File

@ -19,13 +19,13 @@ error: the type `<() as Foo>::Item` is not well-formed
LL | drop(<() as Foo>::copy_me(&x)); LL | drop(<() as Foo>::copy_me(&x));
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: the type `_` is not well-formed error: the type `<() as Foo>::Item` is not well-formed
--> $DIR/alias-bound-unsound.rs:23:5 --> $DIR/alias-bound-unsound.rs:23:5
| |
LL | drop(<() as Foo>::copy_me(&x)); LL | drop(<() as Foo>::copy_me(&x));
| ^^^^ | ^^^^
error: the type `_` is not well-formed error: the type `<() as Foo>::Item` is not well-formed
--> $DIR/alias-bound-unsound.rs:23:10 --> $DIR/alias-bound-unsound.rs:23:10
| |
LL | drop(<() as Foo>::copy_me(&x)); LL | drop(<() as Foo>::copy_me(&x));