NLL: missing "consider using a let binding" message · Issue #49821 · rust-lang/rust (original) (raw)
(NB. This is assuming my in-progress branch)
If you run issue-36082.rs
in NLL mode, you get:
rustc --stage1 issue-36082.rs -Zborrowck=mir error[E0597]: borrowed value does not live long enough --> issue-36082.rs:21:19 | 21 | let val: &_ = x.borrow().0; | ^^^^^^^^^^ - temporary value only lives until here | | | temporary value does not live long enough ... 30 | println!("{}", val); | --- borrow later used here
There is no suggestion about using a let binding to increase the lifetime of the temporary, unlike AST borrowck:
rustc --stage1 issue-36082.rs error[E0597]: borrowed value does not live long enough --> issue-36082.rs:21:19 | 21 | let val: &_ = x.borrow().0; | ^^^^^^^^^^ - temporary value dropped here while still borrowed | | | temporary value does not live long enough ... 31 | } | - temporary value needs to live until here | = note: consider using a
let
binding to increase its lifetime
That said, this seems like a case where the AST borrowck message could also be improved. I doubt many people understand it very well.