From: Jeroen Vannevel Date: Wed, 5 Jan 2022 01:27:15 +0000 (+0000) Subject: failing test for a reference local X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=4c1a1b2570e5d60b49259bea261f7db16ceb627a;p=rust.git failing test for a reference local --- diff --git a/crates/ide_assists/src/handlers/extract_variable.rs b/crates/ide_assists/src/handlers/extract_variable.rs index 39a4700915f..9e11e38d3d6 100644 --- a/crates/ide_assists/src/handlers/extract_variable.rs +++ b/crates/ide_assists/src/handlers/extract_variable.rs @@ -1134,6 +1134,72 @@ struct S { fn foo(s: S) { let $0x = s.sub; x.do_thing(); +}"#, + ); + } + + #[test] + fn test_extract_var_reference_local() { + check_assist( + extract_variable, + r#" +struct X; + +struct S { + sub: X +} + +impl S { + fn new() -> S { + S { + sub: X::new() + } + } +} + +impl X { + fn new() -> X { + X { } + } + fn do_thing(&self) { + + } +} + + +fn foo() { + let local = &mut S::new(); + $0local.sub$0.do_thing(); +}"#, + r#" +struct X; + +struct S { + sub: X +} + +impl S { + fn new() -> S { + S { + sub: X::new() + } + } +} + +impl X { + fn new() -> X { + X { } + } + fn do_thing(&self) { + + } +} + + +fn foo() { + let local = &mut S::new(); + let $0x = local.sub; + x.do_thing(); }"#, ); }