Skip to content

Commit 4c1a1b2

Browse files
committed
failing test for a reference local
1 parent cd5ad4e commit 4c1a1b2

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

crates/ide_assists/src/handlers/extract_variable.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,72 @@ struct S {
11341134
fn foo(s: S) {
11351135
let $0x = s.sub;
11361136
x.do_thing();
1137+
}"#,
1138+
);
1139+
}
1140+
1141+
#[test]
1142+
fn test_extract_var_reference_local() {
1143+
check_assist(
1144+
extract_variable,
1145+
r#"
1146+
struct X;
1147+
1148+
struct S {
1149+
sub: X
1150+
}
1151+
1152+
impl S {
1153+
fn new() -> S {
1154+
S {
1155+
sub: X::new()
1156+
}
1157+
}
1158+
}
1159+
1160+
impl X {
1161+
fn new() -> X {
1162+
X { }
1163+
}
1164+
fn do_thing(&self) {
1165+
1166+
}
1167+
}
1168+
1169+
1170+
fn foo() {
1171+
let local = &mut S::new();
1172+
$0local.sub$0.do_thing();
1173+
}"#,
1174+
r#"
1175+
struct X;
1176+
1177+
struct S {
1178+
sub: X
1179+
}
1180+
1181+
impl S {
1182+
fn new() -> S {
1183+
S {
1184+
sub: X::new()
1185+
}
1186+
}
1187+
}
1188+
1189+
impl X {
1190+
fn new() -> X {
1191+
X { }
1192+
}
1193+
fn do_thing(&self) {
1194+
1195+
}
1196+
}
1197+
1198+
1199+
fn foo() {
1200+
let local = &mut S::new();
1201+
let $0x = local.sub;
1202+
x.do_thing();
11371203
}"#,
11381204
);
11391205
}

0 commit comments

Comments
 (0)