handle late-bound vars from inner binders correctly and add test
This commit is contained in:
parent
e83dcf4ecd
commit
048e637e9e
3 changed files with 25 additions and 1 deletions
|
@ -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, .. }) => {
|
||||
|
|
10
src/test/ui/lifetimes/nested-binder-print.rs
Normal file
10
src/test/ui/lifetimes/nested-binder-print.rs
Normal 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() {}
|
14
src/test/ui/lifetimes/nested-binder-print.stderr
Normal file
14
src/test/ui/lifetimes/nested-binder-print.stderr
Normal 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`.
|
Loading…
Add table
Add a link
Reference in a new issue