Skip to content

Commit

Permalink
handle late-bound vars from inner binders correctly and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
b-naber committed Oct 8, 2022
1 parent e83dcf4 commit 048e637
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, .. }) => {
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/lifetimes/nested-binder-print.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 14 additions & 0 deletions src/test/ui/lifetimes/nested-binder-print.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 048e637

Please sign in to comment.