blob: 6ac68f5adbce8e42224c687ccabc4d72bf728c40 [file] [log] [blame]
//@ edition: 2024
// Regression test for #140583. We want to borrowck nested
// bodies even if they are in dead code. While not necessary for
// soundness, it is desirable to error in such cases.
fn main() {
return;
|x: &str| -> &'static str { x };
//~^ ERROR lifetime may not live long enough
|| {
|| {
let temp = 1;
let p: &'static u32 = &temp;
//~^ ERROR `temp` does not live long enough
};
};
const {
let temp = 1;
let p: &'static u32 = &temp;
//~^ ERROR `temp` does not live long enough
};
async {
let temp = 1;
let p: &'static u32 = &temp;
//~^ ERROR `temp` does not live long enough
};
}