Skip to content

Trying to rename "use alias" in VSCode messes up with files from other crates #5198

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

Open
Tracked by #14079
ararunaufc opened this issue Jul 3, 2020 · 1 comment
Open
Tracked by #14079
Labels
A-ide general IDE features C-bug Category: bug E-unknown It's unclear if the issue is E-hard or E-easy without digging in S-actionable Someone could pick this issue up and work on it right now

Comments

@ararunaufc
Copy link

Hello. I'm not sure what is the "official" name of the renaming imports construct in Rust, so I'm referring to it as "use alias" both in the title and in the body of this issue. Fell free to fix this and delete this part, please.

What is wrong?

When trying to rename the "alias" part of the "use alias" using the Rename Symbol functionality from VSCode (F2), the original name is the one that gets replaced. Moreover, it seems that the change is applied to every source file that uses the previous original name as a mod name in every crate we depend on.

What should happen instead?

I expected that only the new name and its corresponding usages in the current file be changed.

MWE

main.rs

use std::io as foo;

fn main() {
    let _ = foo::empty();
    println!("Hello, world!");
}

Cargo.toml

Just the most basic

Steps taken

  1. click on the foo "alias"
  2. use the "Rename Symbol" utility (F2)
  3. enter the value "bar"
  4. bug!
    4.1. A lot of files get opened by VSCode, none of them from our crate
    4.2 All of the opened files have changes relating to the renaming we tried to do

System info

  • Using VSCode 1.46.1
    • rust-analyser 0.2.224 extension
  • Using rustc 1.44.1
@matklad matklad added the E-unknown It's unclear if the issue is E-hard or E-easy without digging in label Jul 11, 2020
@matklad
Copy link
Member

matklad commented Jul 11, 2020

@matklad matklad added the E-has-instructions Issue has some instructions and pointers to code to get started label Jul 11, 2020
@lnicola lnicola added A-assists S-actionable Someone could pick this issue up and work on it right now labels Jan 18, 2021
bors bot added a commit that referenced this issue Feb 14, 2021
7668: Finalize rename infra rewrite r=matklad a=Veykril

This should be the final PR in regards to rewriting rename stuff, #4290.

It addresses 3 things:
	- Currently renaming import aliases causes some undesired behavior(see #5198) which is why this PR causes us to just return an error if an attempt at renaming an alias is made for the time being. Though this only prevents it from happening when the alias import is renamed, so its not too helpful.
	- Fixes #6898
	- If we are inside a macro file simply rename the input name node as there isn't really a way to do any of the fancy shorthand renames and similar things as for that we would have to exactly know what the macro generates and what not.

Co-authored-by: Lukas Wirth <[email protected]>
@Veykril Veykril removed the E-has-instructions Issue has some instructions and pointers to code to get started label Oct 27, 2022
@Veykril Veykril added the C-bug Category: bug label Feb 9, 2023
@lowr lowr added A-ide general IDE features and removed A-assists labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features C-bug Category: bug E-unknown It's unclear if the issue is E-hard or E-easy without digging in S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

5 participants