1
Fork 0

handle late-bound vars from inner binders correctly and add test

This commit is contained in:
b-naber 2022-10-08 15:52:59 +02:00
parent e83dcf4ecd
commit 048e637e9e
3 changed files with 25 additions and 1 deletions

View file

@ -2093,7 +2093,7 @@ impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
let name = &mut self.name;
let region = match *r {
ty::ReLateBound(db, br) => {
ty::ReLateBound(db, br) if db >= self.current_index => {
*self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br))
}
ty::RePlaceholder(ty::PlaceholderRegion { name: kind, .. }) => {

View file

@ -0,0 +1,10 @@
struct TwoLt<'a, 'b>(&'a (), &'b ());
type Foo<'a> = fn(TwoLt<'_, 'a>);
fn foo() {
let y: for<'a> fn(Foo<'a>);
let x: u32 = y;
//~^ ERROR mismatched types
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/nested-binder-print.rs:6:18
|
LL | let x: u32 = y;
| --- ^ expected `u32`, found fn pointer
| |
| expected due to this
|
= note: expected type `u32`
found fn pointer `for<'a> fn(for<'b> fn(TwoLt<'b, 'a>))`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.