Skip to content
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

Merged
merged 7 commits into from
May 9, 2023

Conversation

Ezrashaw
Copy link
Contributor

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 20, 2023
@@ -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
| ~~~~~~~~
Copy link
Contributor Author

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?

Copy link
Contributor

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).

Copy link
Contributor

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?

@rust-log-analyzer

This comment has been minimized.

Comment on lines +1267 to +1271
} 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())
Copy link
Contributor

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?

Copy link
Contributor Author

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).

Copy link
Contributor Author

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.

@Ezrashaw
Copy link
Contributor Author

Ezrashaw commented Apr 21, 2023

@estebank I'm going to add some more commits and fix that regression. (EDIT: done, ready for review) I suspect there will still be a follow-up PR so this one doesn't get too big.

@rustbot author
@rustbot ready

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 21, 2023
@rust-log-analyzer

This comment has been minimized.

@Ezrashaw Ezrashaw force-pushed the tweak-make-mut-spans branch 2 times, most recently from 3430a3e to 1f5ef60 Compare April 22, 2023 08:54
@bors
Copy link
Contributor

bors commented May 3, 2023

☔ The latest upstream changes (presumably #110579) made this pull request unmergeable. Please resolve the merge conflicts.

Comment on lines 9 to +10
LL | fn reborrow_mut<'a>(t: &'a mut &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy {
| ~~~~~~~~~~~~~~~~~~~
| +++
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the result!

@estebank
Copy link
Contributor

estebank commented May 5, 2023

Sorry I didn't re-review before the merge conflict. r=me after rebase.

@estebank estebank added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2023
@rust-log-analyzer

This comment has been minimized.

@Ezrashaw
Copy link
Contributor Author

Ezrashaw commented May 7, 2023

@estebank Since I don't have those fun r= perms, it'd be great if you could do that :)

@cjgillot
Copy link
Contributor

cjgillot commented May 7, 2023

@bors r=estebank

@bors
Copy link
Contributor

bors commented May 7, 2023

📌 Commit 3e64e98 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 7, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 9, 2023
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
@bors bors merged commit ff30b8c into rust-lang:master May 9, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 9, 2023
@Ezrashaw Ezrashaw deleted the tweak-make-mut-spans branch May 13, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants