-
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
NLL: fix E0594 "change to mutable ref" suggestion #51612
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I broke some tests, didn't I. Gimme a sec. |
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 |
Okay, I think this is ready for review. Sorry about that. |
Hmm I think I may rebase this atop #51275 myself, preserving authorship, just to get it integrated into that rewrite of |
Sounds good! Do you need anything from my end? |
Side note: I just realized I should be matching any whitespace character after |
https://github.com/ashtneoi/rust/tree/51515-missing-first-char-spaces Here's my idea for properly matching the whitespace after |
☔ The latest upstream changes (presumably #51275) made this pull request unmergeable. Please resolve the merge conflicts. |
Should I rebase onto master or merge from it? |
@ashtneoi Always rebase, for Rust PRs. |
Sorry, still working on the rebase---having some trouble finding where the "ref mut" part should go. I'll let y'all know if I can't figure it out. |
@ashtneoi sorry for the radio silence here! @pnkfelix had an unexpected issue and hasn't been able to review PRs etc and I didn't realize this was here. I can try to help you rebase maybe in a bit, but if you want, please do drop in on Zulip where the NLL working group hangs out, maybe we can help? |
in any case, i've assigned this to myself so that I will notice it on my daily PR sweeps =) |
@nikomatsakis Hey, thanks for the update. I was busy with other things today, but I'll throw some questions up on Zulip tomorrow if things still aren't making sense. |
@ashtneoi ok, I read the code. It seems pretty reasonable. Regarding your questions:
Seems about right. The check to look at the source span... is probably good. It's hard to "construct" good suggestions without going back to the source bytes, ultimately, although it often feels a bit hokey.
One thought I had was to check struct Foo { x: u32 }
impl Foo {
fn update(&self) {
self.x += 1;
}
} Does this give a bad suggestion?
Yes
No |
Been kinda busy the past few days, but tomorrow (Wednesday) night I should have some time to look at #51879 and finish rebasing. #51275 changed some aspects of how we do "add |
Status report: I think I have most of a solution and I just need to glue everything together. I'll stop trying to fit everything into a single commit and just push what I have tomorrow (Monday). |
As suggested by @.pnkfelix on Zulip, I'm narrowing the scope to just issue #51515 ( |
c6b7cab
to
a49b75d
Compare
ad4109c
to
6800dea
Compare
I'm not a huge fan of case (1.) here, but I can live with it, and more importantly I think this PR is done. Hopefully I learned my lesson about trying to do too much at once. |
6800dea
to
dc8ae26
Compare
Actually |
@bors r+ rollup |
📌 Commit dc8ae26 has been approved by |
NLL: fix E0594 "change to mutable ref" suggestion Fix #51515. Fix #51879. Questions: - [x] Is this the right place to fix this? It feels brittle, being so close to the frontend. **It's probably fine.** - [ ] Have I missed any other cases that trigger this behavior? - [x] Is it okay to use HELP and SUGGESTION in the UI test? **Yes.** - [x] Do I need more tests for this? **No.**
…r=pnkfelix NLL: fix E0594 "change to mutable ref" suggestion Fix rust-lang#51515. Fix rust-lang#51879. Questions: - [x] Is this the right place to fix this? It feels brittle, being so close to the frontend. **It's probably fine.** - [ ] Have I missed any other cases that trigger this behavior? - [x] Is it okay to use HELP and SUGGESTION in the UI test? **Yes.** - [x] Do I need more tests for this? **No.**
☀️ Test successful - status-appveyor, status-travis |
Rollup of 7 pull requests Successful merges: - #51612 (NLL: fix E0594 "change to mutable ref" suggestion) - #51722 (Updated RELEASES for 1.28.0) - #52064 (Clarifying how the alignment of the struct works) - #52149 (Add #[repr(transparent)] to Atomic* types) - #52151 (Trait impl settings) - #52171 (Correct some codegen stats counter inconsistencies) - #52195 (rustc: Avoid /tmp/ in graphviz writing) Failed merges: - #52164 (use proper footnote syntax for references) r? @ghost
NLL: Suggest `ref mut` and `&mut self` Fixes rust-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.)
Fix #51515.
Fix #51879.
Questions: