@@ -18,9 +18,9 @@ use ra_db::FileId;
1818use ra_fmt:: leading_indent;
1919use rustc_hash:: FxHashSet ;
2020
21- // Assist extract_struct_from_enum
21+ // Assist: extract_struct_from_enum_variant
2222//
23- // Extracts a struct from enum variant
23+ // Extracts a struct from enum variant.
2424//
2525// ```
2626// enum A { <|>One(u32, u32) }
@@ -29,9 +29,12 @@ use rustc_hash::FxHashSet;
2929// ```
3030// struct One(pub u32, pub u32);
3131//
32- // enum A { One(One) }"
32+ // enum A { One(One) }
3333// ```
34- pub ( crate ) fn extract_struct_from_enum ( acc : & mut Assists , ctx : & AssistContext ) -> Option < ( ) > {
34+ pub ( crate ) fn extract_struct_from_enum_variant (
35+ acc : & mut Assists ,
36+ ctx : & AssistContext ,
37+ ) -> Option < ( ) > {
3538 let variant = ctx. find_node_at_offset :: < ast:: EnumVariant > ( ) ?;
3639 let field_list = match variant. kind ( ) {
3740 ast:: StructKind :: Tuple ( field_list) => field_list,
@@ -221,7 +224,7 @@ mod tests {
221224 #[ test]
222225 fn test_extract_struct_several_fields ( ) {
223226 check_assist (
224- extract_struct_from_enum ,
227+ extract_struct_from_enum_variant ,
225228 "enum A { <|>One(u32, u32) }" ,
226229 r#"struct One(pub u32, pub u32);
227230
@@ -232,7 +235,7 @@ enum A { One(One) }"#,
232235 #[ test]
233236 fn test_extract_struct_one_field ( ) {
234237 check_assist (
235- extract_struct_from_enum ,
238+ extract_struct_from_enum_variant ,
236239 "enum A { <|>One(u32) }" ,
237240 r#"struct One(pub u32);
238241
@@ -243,7 +246,7 @@ enum A { One(One) }"#,
243246 #[ test]
244247 fn test_extract_struct_pub_visibility ( ) {
245248 check_assist (
246- extract_struct_from_enum ,
249+ extract_struct_from_enum_variant ,
247250 "pub enum A { <|>One(u32, u32) }" ,
248251 r#"pub struct One(pub u32, pub u32);
249252
@@ -254,7 +257,7 @@ pub enum A { One(One) }"#,
254257 #[ test]
255258 fn test_extract_struct_with_complex_imports ( ) {
256259 check_assist (
257- extract_struct_from_enum ,
260+ extract_struct_from_enum_variant ,
258261 r#"mod my_mod {
259262 fn another_fn() {
260263 let m = my_other_mod::MyEnum::MyField(1, 1);
@@ -305,7 +308,7 @@ fn another_fn() {
305308 fn check_not_applicable ( ra_fixture : & str ) {
306309 let fixture =
307310 format ! ( "//- main.rs crate:main deps:core\n {}\n {}" , ra_fixture, FamousDefs :: FIXTURE ) ;
308- check_assist_not_applicable ( extract_struct_from_enum , & fixture)
311+ check_assist_not_applicable ( extract_struct_from_enum_variant , & fixture)
309312 }
310313
311314 #[ test]
0 commit comments