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

"Inline variable" refactoring doesn't consider references inside format strings #14785

Closed
MariaSolOs opened this issue May 11, 2023 · 2 comments
Labels
C-bug Category: bug

Comments

@MariaSolOs
Copy link
Contributor

rust-analyzer version: 0.4.1509-standalone (b7cdd93 2023-05-09)

rustc version: 1.68.0 (2c8cc3432 2023-03-06)

To reproduce the bug:

  1. Write the following code.
fn foo() -> u32 {
    let bar = 1 + 1;
    println!("{bar}");
    bar + 2
}
  1. Request code actions in any reference of bar and select "Inline variable".
  2. Notice how the refactoring will remove the declaration of bar and update the return statement, but it won't change the print statement, causing an error because bar isn't there anymore.

Also, changing the print statement to println!("{}", bar) does fix the issue, so it seems to be the reference inside the format string that's problematic.

@MariaSolOs MariaSolOs added the C-bug Category: bug label May 11, 2023
@jhgg
Copy link
Contributor

jhgg commented May 12, 2023

This is #11260

@Veykril Veykril closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
@MariaSolOs
Copy link
Contributor Author

Oops, sorry for the duplicate :(

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

No branches or pull requests

3 participants