-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
tweak "make mut" spans when assigning to locals #110583
Conversation
@@ -6,8 +6,8 @@ LL | *input = self.0; | |||
| | |||
help: consider changing that to be a mutable reference | |||
| | |||
LL | fn example(&self, input: &mut i32); // should suggest here | |||
| ~~~~~~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave this for a follow-up PR if that's OK with you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is causing a clear visual regression I would prefer to investigate further and try to land the whole fix in a single PR (to avoid risking this slipping into beta by accident simply because we forgot to follow up).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now fixed, right?
This comment has been minimized.
This comment has been minimized.
fb690f8
to
57d603e
Compare
} else if binding_exists { | ||
// shrink the span to just after the `&` in `&variable` | ||
let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo(); | ||
(true, span, "mut ".to_owned()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the test presenting the small regression, can you check that you're actually falling into this branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it does. The problem is that there is a call to is_error_in_trait
after this function returns which overwrites the returned span (but not the string suggestion) to point to the trait (if local).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed it so that we call is_error_in_trait
before all the suggestion logic and integrate the spans from that. See the latest commit.
This comment has been minimized.
This comment has been minimized.
3430a3e
to
1f5ef60
Compare
☔ The latest upstream changes (presumably #110579) made this pull request unmergeable. Please resolve the merge conflicts. |
LL | fn reborrow_mut<'a>(t: &'a mut &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
| +++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the result!
Sorry I didn't re-review before the merge conflict. r=me after rebase. |
1f5ef60
to
13288d8
Compare
This comment has been minimized.
This comment has been minimized.
13288d8
to
3e64e98
Compare
@estebank Since I don't have those fun |
@bors r=estebank |
Rollup of 7 pull requests Successful merges: - rust-lang#110304 (Add GNU Property Note) - rust-lang#110504 (Tweak borrow suggestion span) - rust-lang#110583 (tweak "make mut" spans when assigning to locals) - rust-lang#110694 (Implement builtin # syntax and use it for offset_of!(...)) - rust-lang#111120 (Suggest let for possible binding with ty) - rust-lang#111252 (Min specialization improvements) - rust-lang#111361 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Work towards fixing #106857
This PR just cleans up a lot of spans which is helpful before properly fixing the issues. Best reviewed commit-by-commit.
r? @estebank