-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #103780 - compiler-errors:bound-closure-lifetimes, r=…
…jackh726 Fix late-bound lifetime closure ICEs in HIR typeck and MIR borrowck During HIR typeck, we need to teach astconv to treat late-bound regions within a closure body as free, fixing escaping bound vars ICEs in both of the issues below. However, this then gets us to MIR borrowck, which itself needs to be taught how to instantiate free region vids for late-bound regions that come from items that _aren't_ the typeck root (for now, just closures). Fixes #103771 Fixes #103736
- Loading branch information
Showing
7 changed files
with
161 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// check-pass | ||
|
||
#![feature(closure_lifetime_binder)] | ||
|
||
fn main() { | ||
let _ = for<'a> || -> () { | ||
let _: &'a bool = &true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// check-pass | ||
|
||
#![feature(closure_lifetime_binder)] | ||
#![feature(rustc_attrs)] | ||
|
||
#[rustc_regions] | ||
fn main() { | ||
for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/ui/closures/binder/nested-closures-regions.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
note: external requirements | ||
--> $DIR/nested-closures-regions.rs:8:24 | ||
| | ||
LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: defining type: main::{closure#0}::{closure#0} with closure substs [ | ||
i8, | ||
extern "rust-call" fn((&(),)), | ||
(), | ||
] | ||
= note: late-bound region is '_#4r | ||
= note: late-bound region is '_#2r | ||
= note: number of external vids: 3 | ||
= note: where '_#1r: '_#2r | ||
= note: where '_#2r: '_#1r | ||
|
||
note: no external requirements | ||
--> $DIR/nested-closures-regions.rs:8:5 | ||
| | ||
LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: defining type: main::{closure#0} with closure substs [ | ||
i8, | ||
extern "rust-call" fn(()), | ||
(), | ||
] | ||
= note: late-bound region is '_#2r | ||
|
||
note: no external requirements | ||
--> $DIR/nested-closures-regions.rs:7:1 | ||
| | ||
LL | fn main() { | ||
| ^^^^^^^^^ | ||
| | ||
= note: defining type: main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// check-pass | ||
|
||
#![feature(closure_lifetime_binder)] | ||
|
||
fn main() { | ||
for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; | ||
} |