From 4a16c228e7a3f69b7ac102be5c35ab6d3af9c827 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 9 Nov 2020 16:40:41 +0100 Subject: Fix panic when extracting struct --- .../handlers/extract_struct_from_enum_variant.rs | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'crates/assists/src/handlers') diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs index 58aadcef7..84662d832 100644 --- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs @@ -378,6 +378,36 @@ use crate::E; fn f() { let e = E::V(V(9, 2)); } +"#, + ) + } + + #[test] + fn test_several_files_record() { + // FIXME: this should fix the usage as well! + check_assist( + extract_struct_from_enum_variant, + r#" +//- /main.rs +enum E { + <|>V { i: i32, j: i32 } +} +mod foo; + +//- /foo.rs +use crate::E; +fn f() { + let e = E::V { i: 9, j: 2 }; +} +"#, + r#" +struct V{ pub i: i32, pub j: i32 } + +enum E { + V(V) +} +mod foo; + "#, ) } -- cgit v1.2.3