vscode-rust icon indicating copy to clipboard operation
vscode-rust copied to clipboard

Renaming items also renames the crate keyword

Open neverRare opened this issue 5 years ago • 0 comments

Steps to reproduce:

  1. Create a new library crate, in lib.rs copy-paste the following code.
enum EnumTest {}

mod test {
    use crate::EnumTest;
}
  1. Using rename symbol feature, rename the EnumTest in first line to anything else. It would result to the following code.
enum AnythingElse {}

mod test {
    use AnythingElse::AnythingElse;
}

As you can see, it also renames the crate keyword, which is unexpected.

Interestingly, using glob-like brace syntax on use declaration, i.e. use crate::{EnumTest, anything_else_here}, will cause renaming to fail. Another interesting note is that when I tried this with struct, it fails to rename. So I tested it with other kinds of items: struct, enum, type alias, union, trait, function, const, and static; it appears almost all kinds of items that I tested have the same behavior when renaming with exception to struct. I used the following code for completeness.

struct StructTest;
enum EnumTest {}
type TypeTest = StructTest;
union UnionTest {
    test: i32,
}
trait TraitTest {}
fn function_test() {}
const CONST_TEST: i32 = 10;
static STATIC_TEST: i32 = 10;

mod test {
    use crate::function_test;
    use crate::EnumTest;
    use crate::StructTest;
    use crate::TraitTest;
    use crate::TypeTest;
    use crate::UnionTest;
    use crate::CONST_TEST;
    use crate::STATIC_TEST;
}

VSCode version: 1.50.1 (user setup) OS: Windows_NT x64 10.0.18363 Rust extension version: v0.7.8

neverRare avatar Oct 29 '20 01:10 neverRare