Closed
Description
Code
#![feature(closure_lifetime_binder, inline_const)]
fn foo() {
let a = for<'a> |b: &'a ()| -> &'a () {
const {
let awd = ();
let _: &'a () = &awd;
};
b
};
}
Current output
error[E0597]: `awd` does not live long enough
--> src/lib.rs:7:29
|
4 | let a = for<'a> |b: &'a ()| -> &'a () {
| -- lifetime `'a` defined here
...
7 | let _: &'a () = &awd;
| ------ ^^^^ borrowed value does not live long enough
| |
| type annotation requires that `awd` is borrowed for `'a`
8 | };
| - `awd` dropped here while still borrowed
note: erroneous constant used
--> src/lib.rs:5:9
|
5 | / const {
6 | | let awd = ();
7 | | let _: &'a () = &awd;
8 | | };
| |_________^
Desired output
error[E0597]: `awd` does not live long enough
--> src/lib.rs:7:29
|
4 | let a = for<'a> |b: &'a ()| -> &'a () {
| -- lifetime `'a` defined here
...
7 | let _: &'a () = &awd;
| ------ ^^^^ borrowed value does not live long enough
| |
| type annotation requires that `awd` is borrowed for `'a`
8 | };
| - `awd` dropped here while still borrowed
Rationale and extra context
No response
Other cases
No response
Anything else?
No response