Auto merge of #89345 - jackh726:89333, r=estebank

Don't lose binders when printing trait bound suggestion

Fixes #89333
This commit is contained in:
bors 2021-10-02 21:30:51 +00:00
commit 2801a770ce
3 changed files with 42 additions and 16 deletions

View file

@ -0,0 +1,11 @@
// check-fail
// Ensure we don't error when emitting trait bound not satisfied when self type
// has late bound var
fn main() {
test(&|| 0); //~ ERROR the trait bound
}
trait Trait {}
fn test<T>(arg: &impl Fn() -> T) where for<'a> &'a T: Trait {}

View file

@ -0,0 +1,15 @@
error[E0277]: the trait bound `for<'a> &'a _: Trait` is not satisfied
--> $DIR/issue-89333.rs:6:5
|
LL | test(&|| 0);
| ^^^^ the trait `for<'a> Trait` is not implemented for `&'a _`
|
note: required by a bound in `test`
--> $DIR/issue-89333.rs:11:55
|
LL | fn test<T>(arg: &impl Fn() -> T) where for<'a> &'a T: Trait {}
| ^^^^^ required by this bound in `test`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.