Skip to content

Commit 048e637

Browse files
committed
handle late-bound vars from inner binders correctly and add test
1 parent e83dcf4 commit 048e637

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2093,7 +2093,7 @@ impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
20932093
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
20942094
let name = &mut self.name;
20952095
let region = match *r {
2096-
ty::ReLateBound(db, br) => {
2096+
ty::ReLateBound(db, br) if db >= self.current_index => {
20972097
*self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br))
20982098
}
20992099
ty::RePlaceholder(ty::PlaceholderRegion { name: kind, .. }) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct TwoLt<'a, 'b>(&'a (), &'b ());
2+
type Foo<'a> = fn(TwoLt<'_, 'a>);
3+
4+
fn foo() {
5+
let y: for<'a> fn(Foo<'a>);
6+
let x: u32 = y;
7+
//~^ ERROR mismatched types
8+
}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/nested-binder-print.rs:6:18
3+
|
4+
LL | let x: u32 = y;
5+
| --- ^ expected `u32`, found fn pointer
6+
| |
7+
| expected due to this
8+
|
9+
= note: expected type `u32`
10+
found fn pointer `for<'a> fn(for<'b> fn(TwoLt<'b, 'a>))`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)