-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsF-closure_lifetime_binder`#![feature(closure_lifetime_binder)]``#![feature(closure_lifetime_binder)]`F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)Inline constants (aka: const blocks, const expressions, anonymous constants)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsF-closure_lifetime_binder`#![feature(closure_lifetime_binder)]``#![feature(closure_lifetime_binder)]`F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)Inline constants (aka: const blocks, const expressions, anonymous constants)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.