From 924eecf4af4d57c597c2e77c5e58c22b2a37bdb6 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 14 Nov 2020 19:11:09 +0100 Subject: Properly handle shorthands in destructure patterns when renaming --- crates/ide/src/references/rename.rs | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'crates/ide/src/references') diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index b3ade20ef..bc4aa25bf 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs @@ -1135,6 +1135,60 @@ struct Foo { bar: i32 } fn foo(bar: i32) -> Foo { Foo { bar } } +"#, + ); + } + + #[test] + fn test_rename_binding_in_destructure_pat_shorthand() { + check( + "bar", + r#" +struct Foo { + i: i32, +} + +fn foo(foo: Foo) { + let Foo { i } = foo; + let _ = i<|>; +} +"#, + r#" +struct Foo { + i: i32, +} + +fn foo(foo: Foo) { + let Foo { i: bar } = foo; + let _ = bar; +} +"#, + ); + } + + #[test] + fn test_rename_binding_in_destructure_pat() { + check( + "bar", + r#" +struct Foo { + i: i32, +} + +fn foo(foo: Foo) { + let Foo { i: b } = foo; + let _ = b<|>; +} +"#, + r#" +struct Foo { + i: i32, +} + +fn foo(foo: Foo) { + let Foo { i: bar } = foo; + let _ = bar; +} "#, ); } -- cgit v1.2.3