-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIR-borrowck: add "consider changing this to mut x
" note, as in AST borrowck
#46020
Comments
Note: this is somewhat lower priority than the rest of the NLL work. How to implement thisThe AST borrow-checker has mutability blaming code in the following place: rust/src/librustc_borrowck/borrowck/mod.rs Line 1193 in f28df20
That code needs to be ported to MIR borrowck. The code uses the The AST borrowck looks up data on user local variables using the local's NodeId in order to make this error report. Therefore, it might probably a good idea to change the |
I'd like to take this one. I already took #46186(at least I wrote i'd like to :) ), they touch different parts of diagnostic system(as far as I can see now), so I'd like to solve both to get a taste of what's going on from different angles. |
Cool! If you have any questions, feel free to ping me on WG-compiler-nll or WG-compiler-errors on gitter. |
@raventid I'm guessing you never found time to do this, right? (No worries, just checking in.) |
@nikomatsakis, yep. To be frank - I even forgot I started this. I actually had some time to tweak this a bit, but it happend to be a bit harder then I expected, I didn't manage to find a way to easily port |
@spastorino is gonna take a crack at this I think |
This test: #![feature(nll)]
#![allow(warnings)]
fn main() {
let x = 0;
x = 1;
std::mem::replace(&mut x, 2);
} currently gives:
Note that we do provide the hints, but we also report duplicate errors. |
Well, the AST version does too:
|
I am going to close this as fixed. |
Currently, when you try to access an immutable local, AST borrowck suggests that you should change it to
mut x
, for example:MIR borrowck should be doing this too.
FIXME: I should write mentor notes
The text was updated successfully, but these errors were encountered: