Uh oh!
There was an error while loading. Please reload this page.
Fix wrong test replacemen in ref mut suggestion - #51249
Conversation
rust-highfive
commented
May 31, 2018
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
35ba512 to
fb30eb6Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
This is (a) not requiring the ref to be at the start of the span (this might be problematic) and (b) only matching the first space after it (this is okay if we want to preserve weird formatting). This might be fine for all inputs we consider now, but matching "^ref " seems safer in general.
ce7540a to
cc50347Compare
This comment has been minimized.
This comment has been minimized.
the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
TimNN
commented
Jun 12, 2018
Friendly triage ping @pnkfelix / @rust-lang/compiler, it looks like this PR needs your review. |
There was a problem hiding this comment.
Could we change this to be a span_suggestion? That way editors will know they can perform the replacement and the following code:
let replace_str = if snippet.starts_with("ref ") {
snippet.replacen("ref ", "ref mut ", 1)
} else {
snippet
};
db.span_label(
let_span,
"use a mutable reference instead",
replace_str,
);
output would look like this:
error[E0594]: cannot assign to immutable borrowed content `*my_ref`
--> $DIR/issue-51244.rs:13:5
|
LL | let ref my_ref @ _ = 0;
| -------------- use a mutable reference instead: `ref mut my_ref @ _`
LL | *my_ref = 0;
| ^^^^^^^^^^^ cannot borrow as mutable
This will likely require you to run ./x.py test src/test/ui --bless to update the output in other test files too.
If you do not wish to make this change now, please file a ticket to follow up on all suggestions on this file, so that the team doesn't forget to address this later.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Use |
@estebank I did In the origin suggestion: changing to And this time, the span( |
estebank
commented
Jun 15, 2018
You're right, although I would say that that is probably a preexisting problem (the current suggestion is already wrong). It needs to be fixed, but it doesn't seem to be a regression caused by your code. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rust-highfive
commented
Jun 22, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
stokhos
commented
Jun 30, 2018
ping from triage @csmoe will you have time to fix the code? |
emilyalbini
commented
Jul 9, 2018
@csmoe this is blocked on what? |
NLL: Suggest `ref mut` and `&mut self` Fixesrust-lang#51244. Supersedes rust-lang#51249, I think. Under the old lexical lifetimes, the compiler provided helpful suggestions about adding `mut` when you tried to mutate a variable bound as `&self` or (explicit) `ref`. NLL doesn't have those suggestions yet. This pull request adds them. I didn't bother making the help text exactly the same as without NLL, but I can if that's important. (Originally this was supposed to be part of rust-lang#51612, but I got bogged down trying to fit everything in one PR.)
NLL: Suggest `ref mut` and `&mut self` Fixes#51244. Supersedes #51249, I think. Under the old lexical lifetimes, the compiler provided helpful suggestions about adding `mut` when you tried to mutate a variable bound as `&self` or (explicit) `ref`. NLL doesn't have those suggestions yet. This pull request adds them. I didn't bother making the help text exactly the same as without NLL, but I can if that's important. (Originally this was supposed to be part of #51612, but I got bogged down trying to fit everything in one PR.)
bors
commented
Jul 13, 2018
☔ The latest upstream changes (presumably #52242) made this pull request unmergeable. Please resolve the merge conflicts. |
csmoe
commented
Jul 13, 2018
Fixed #52242 |
Closes#51244