From 5e765895cf6fea42649a846c0297d95a9aa7b162 Mon Sep 17 00:00:00 2001 From: unexge Date: Fri, 23 Apr 2021 16:18:10 +0300 Subject: Add missing test case for "Convert to named struct" assist --- .../convert_tuple_struct_to_named_struct.rs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs b/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs index cac4bec3d..b5b5ada5e 100644 --- a/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs +++ b/crates/ide_assists/src/handlers/convert_tuple_struct_to_named_struct.rs @@ -418,6 +418,46 @@ impl Outer { let Outer(Inner { field1: x }) = self; x } +}"#, + ); + + check_assist( + convert_tuple_struct_to_named_struct, + r#" +struct Inner(u32); +struct Outer$0(Inner); + +impl Outer { + fn new() -> Self { + Self(Inner(42)) + } + + fn into_inner(self) -> u32 { + (self.0).0 + } + + fn into_inner_destructed(self) -> u32 { + let Outer(Inner(x)) = self; + x + } +}"#, + r#" +struct Inner(u32); +struct Outer { field1: Inner } + +impl Outer { + fn new() -> Self { + Self { field1: Inner(42) } + } + + fn into_inner(self) -> u32 { + (self.field1).0 + } + + fn into_inner_destructed(self) -> u32 { + let Outer { field1: Inner(x) } = self; + x + } }"#, ); } -- cgit v1.2.3