Closed
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 | 💯 |