Skip to content

Commit fa0afb9

Browse files
committed
additional test for a reference local (on top of mutable reference local)
1 parent 4c1a1b2 commit fa0afb9

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

crates/ide_assists/src/handlers/extract_variable.rs

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ fn foo(s: S) {
11391139
}
11401140

11411141
#[test]
1142-
fn test_extract_var_reference_local() {
1142+
fn test_extract_var_mutable_reference_local() {
11431143
check_assist(
11441144
extract_variable,
11451145
r#"
@@ -1198,7 +1198,73 @@ impl X {
11981198
11991199
fn foo() {
12001200
let local = &mut S::new();
1201-
let $0x = local.sub;
1201+
let $0x = &mut local.sub;
1202+
x.do_thing();
1203+
}"#,
1204+
);
1205+
}
1206+
1207+
#[test]
1208+
fn test_extract_var_reference_local() {
1209+
check_assist(
1210+
extract_variable,
1211+
r#"
1212+
struct X;
1213+
1214+
struct S {
1215+
sub: X
1216+
}
1217+
1218+
impl S {
1219+
fn new() -> S {
1220+
S {
1221+
sub: X::new()
1222+
}
1223+
}
1224+
}
1225+
1226+
impl X {
1227+
fn new() -> X {
1228+
X { }
1229+
}
1230+
fn do_thing(&self) {
1231+
1232+
}
1233+
}
1234+
1235+
1236+
fn foo() {
1237+
let local = &S::new();
1238+
$0local.sub$0.do_thing();
1239+
}"#,
1240+
r#"
1241+
struct X;
1242+
1243+
struct S {
1244+
sub: X
1245+
}
1246+
1247+
impl S {
1248+
fn new() -> S {
1249+
S {
1250+
sub: X::new()
1251+
}
1252+
}
1253+
}
1254+
1255+
impl X {
1256+
fn new() -> X {
1257+
X { }
1258+
}
1259+
fn do_thing(&self) {
1260+
1261+
}
1262+
}
1263+
1264+
1265+
fn foo() {
1266+
let local = &S::new();
1267+
let $0x = &local.sub;
12021268
x.do_thing();
12031269
}"#,
12041270
);

0 commit comments

Comments
 (0)