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

"Convert identifier to uppercase" code assist doesn't replace references to the variable #15319

Closed
MariaSolOs opened this issue Jul 20, 2023 · 7 comments · Fixed by #15320
Closed
Labels
A-diagnostics diagnostics / error reporting C-bug Category: bug

Comments

@MariaSolOs
Copy link
Contributor

rust-analyzer version: 0.3.1591-standalone (d824511 2023-07-16)

rustc version: rustc 1.72.0-nightly (37998ab50 2023-06-11)

Given the following code:

    const should_foo: bool = true;
    if should_foo {
        println!("foo");
    } else {
        println!("bar");
    }

rust-analyzer will display the "Convert the identifier to upper case" code assist. However, when applying the refactoring only the declaration is updated, not the references.

And so the outcome is:

    const SHOULD_FOO: bool = true;
    if should_foo { // error
        println!("foo");
    } else {
        println!("bar");
    }
@MariaSolOs MariaSolOs added the C-bug Category: bug label Jul 20, 2023
@lowr lowr added the A-diagnostics diagnostics / error reporting label Jul 21, 2023
@lnicola
Copy link
Member

lnicola commented Jul 21, 2023

Are you sure about this? Our diagnostic doesn't trigger for inner items, but otherwise the fix works just fine:

image

image

Then there's also the warning from rustc which doesn't work properly, CC #7742:

image

@lowr
Copy link
Contributor

lowr commented Jul 21, 2023

The diagnostic mentioned in OP does come from rustc, which doesn't account for name references, but we should be also reporting the diagnostics for them anyway. #15320 should fix that.

@bors bors closed this as completed in 59d35d2 Jul 21, 2023
@MariaSolOs
Copy link
Contributor Author

And as always, I’m impressed by the bug fixing speed of y’all. Thanks a lot!

@MariaSolOs
Copy link
Contributor Author

@lowr @lnicola Hello again! Quick question: With the latest version of RA I'm now seeing the 2 code actions below:

image

The first one does correctly update references, while the 2nd one (which is the one I originally mentioned in this issue) still only updates the declaration. I'm not asking for further changes, I just want to better understand the difference between them.

@MariaSolOs
Copy link
Contributor Author

In particular, from the description of #15320 it sounds like RA just started providing those refactorings, and so who's providing the 2nd one? Because from the UI above it looks like RA is the only code action provider...

@lnicola
Copy link
Member

lnicola commented Jul 25, 2023

It's from rustc (cargo check), see my comment above.

@MariaSolOs
Copy link
Contributor Author

It's from rustc (cargo check), see my comment above.

Oh I'm so sorry, I missed that very important last sentence. My bad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants