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
Historically, we have considered
let _ = footo be a no-op. That is, it does not read or "access"fooin 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):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
let _ = <unsafe-field>match <unsafe_field> { _ => () }let _ = <moved>match <moved> { _ => () }let _ = <borrowed>match <borrowed> { _ => () }