diff options
author | Lukas Wirth <[email protected]> | 2020-11-14 18:11:09 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-11-14 18:11:09 +0000 |
commit | 924eecf4af4d57c597c2e77c5e58c22b2a37bdb6 (patch) | |
tree | de445be048cad200c909464ad5687ecaa71e5ca1 /crates/ide/src/references | |
parent | e55a44a831477e2fc8e11340c3d91db883b97c8e (diff) |
Properly handle shorthands in destructure patterns when renaming
Diffstat (limited to 'crates/ide/src/references')
-rw-r--r-- | crates/ide/src/references/rename.rs | 54 |
1 files changed, 54 insertions, 0 deletions
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 | |||
@@ -1138,4 +1138,58 @@ fn foo(bar: i32) -> Foo { | |||
1138 | "#, | 1138 | "#, |
1139 | ); | 1139 | ); |
1140 | } | 1140 | } |
1141 | |||
1142 | #[test] | ||
1143 | fn test_rename_binding_in_destructure_pat_shorthand() { | ||
1144 | check( | ||
1145 | "bar", | ||
1146 | r#" | ||
1147 | struct Foo { | ||
1148 | i: i32, | ||
1149 | } | ||
1150 | |||
1151 | fn foo(foo: Foo) { | ||
1152 | let Foo { i } = foo; | ||
1153 | let _ = i<|>; | ||
1154 | } | ||
1155 | "#, | ||
1156 | r#" | ||
1157 | struct Foo { | ||
1158 | i: i32, | ||
1159 | } | ||
1160 | |||
1161 | fn foo(foo: Foo) { | ||
1162 | let Foo { i: bar } = foo; | ||
1163 | let _ = bar; | ||
1164 | } | ||
1165 | "#, | ||
1166 | ); | ||
1167 | } | ||
1168 | |||
1169 | #[test] | ||
1170 | fn test_rename_binding_in_destructure_pat() { | ||
1171 | check( | ||
1172 | "bar", | ||
1173 | r#" | ||
1174 | struct Foo { | ||
1175 | i: i32, | ||
1176 | } | ||
1177 | |||
1178 | fn foo(foo: Foo) { | ||
1179 | let Foo { i: b } = foo; | ||
1180 | let _ = b<|>; | ||
1181 | } | ||
1182 | "#, | ||
1183 | r#" | ||
1184 | struct Foo { | ||
1185 | i: i32, | ||
1186 | } | ||
1187 | |||
1188 | fn foo(foo: Foo) { | ||
1189 | let Foo { i: bar } = foo; | ||
1190 | let _ = bar; | ||
1191 | } | ||
1192 | "#, | ||
1193 | ); | ||
1194 | } | ||
1141 | } | 1195 | } |