From 4c1a1b2570e5d60b49259bea261f7db16ceb627a Mon Sep 17 00:00:00 2001 From: Jeroen Vannevel Date: Wed, 5 Jan 2022 01:27:15 +0000 Subject: [PATCH] failing test for a reference local --- .../src/handlers/extract_variable.rs | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) 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(); }"#, ); } -- 2.44.0