-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)NLL-completeWorking towards the "valid code works" goalWorking towards the "valid code works" goalP-mediumMedium priorityMedium priorityT-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.WG-nllWorking group: Non-lexical lifetimesWorking group: Non-lexical lifetimes
Description
Historically, we have considered let _ = foo
to be a no-op. That is, it does not read or "access" foo
in any way. This is why the following code compiles normally. However, it does NOT compile with NLL, because we have an "artificial read" of the matched value (or so it seems):
#![feature(nll)]
#![allow(unused_variables)]
struct Vi<'a> {
ed: Editor<'a>,
}
struct Editor<'a> {
ctx: &'a mut Context,
}
struct Context {
data: bool,
}
impl Context {
fn read_line(&mut self) {
let ed = Editor { ctx: self };
match self.data {
_ => {
let vi = Vi { ed };
}
}
}
}
fn main() {
}
Found in liner-0.4.4.
I believe that we added this artificial read in order to fix #47412, which had to do with enum reads and so forth. It seems like that fix was a bit too strong (cc @eddyb).
UPDATE: Current status as of 2018-10-02
Thing | AST | MIR | Want | Example | Issue |
---|---|---|---|---|---|
let _ = <unsafe-field> |
💚 | 💚 | ❌ | playground | #54003 |
match <unsafe_field> { _ => () } |
❌ | ❌ | ❌ | playground | #54003 |
let _ = <moved> |
💚 | 💚 | 💚 | playground | 💯 |
match <moved> { _ => () } |
❌ | ❌ | 💚 | playground | |
let _ = <borrowed> |
💚 | 💚 | 💚 | playground | 💯 |
match <borrowed> { _ => () } |
💚 | 💚 | 💚 | playground | 💯 |
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)NLL-completeWorking towards the "valid code works" goalWorking towards the "valid code works" goalP-mediumMedium priorityMedium priorityT-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.WG-nllWorking group: Non-lexical lifetimesWorking group: Non-lexical lifetimes