Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/rename.rs')
| -rw-r--r-- | crates/ide/src/rename.rs | 67 |
1 files changed, 63 insertions, 4 deletions
diff --git a/crates/ide/src/rename.rs b/crates/ide/src/rename.rs index 900a885a64..2c6116f745 100644 --- a/crates/ide/src/rename.rs +++ b/crates/ide/src/rename.rs @@ -1326,8 +1326,8 @@ impl Foo { struct Foo { foo$0: i32 } impl Foo { - fn new(foo: i32) -> Self { - Self { foo } + fn foo(foo: i32) { + Self { foo }; } } "#, @@ -1335,8 +1335,8 @@ impl Foo { struct Foo { field: i32 } impl Foo { - fn new(foo: i32) -> Self { - Self { field: foo } + fn foo(foo: i32) { + Self { field: foo }; } } "#, @@ -3930,4 +3930,63 @@ fn bar() { "#, ); } + + #[test] + fn rename_constructor_locals() { + check( + "field", + r#" +struct Struct { + struct_field$0: String, +} + +impl Struct { + fn new(struct_field: String) -> Self { + if false { + return Self { struct_field }; + } + Self { struct_field } + } +} + +mod foo { + macro_rules! m { + ($it:expr) => { return $it }; + } + + impl crate::Struct { + fn with_foo(struct_field: String) -> crate::Struct { + m!(crate::Struct { struct_field }); + } + } +} + "#, + r#" +struct Struct { + field: String, +} + +impl Struct { + fn new(field: String) -> Self { + if false { + return Self { field }; + } + Self { field } + } +} + +mod foo { + macro_rules! m { + ($it:expr) => { return $it }; + } + + impl crate::Struct { + fn with_foo(field: String) -> crate::Struct { + m!(crate::Struct { field }); + } + } +} + "#, + ); + } } |