@@ -18,9 +18,9 @@ use ra_db::FileId;
18
18
use ra_fmt:: leading_indent;
19
19
use rustc_hash:: FxHashSet ;
20
20
21
- // Assist extract_struct_from_enum
21
+ // Assist: extract_struct_from_enum_variant
22
22
//
23
- // Extracts a struct from enum variant
23
+ // Extracts a struct from enum variant.
24
24
//
25
25
// ```
26
26
// enum A { <|>One(u32, u32) }
@@ -29,9 +29,12 @@ use rustc_hash::FxHashSet;
29
29
// ```
30
30
// struct One(pub u32, pub u32);
31
31
//
32
- // enum A { One(One) }"
32
+ // enum A { One(One) }
33
33
// ```
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 < ( ) > {
35
38
let variant = ctx. find_node_at_offset :: < ast:: EnumVariant > ( ) ?;
36
39
let field_list = match variant. kind ( ) {
37
40
ast:: StructKind :: Tuple ( field_list) => field_list,
@@ -221,7 +224,7 @@ mod tests {
221
224
#[ test]
222
225
fn test_extract_struct_several_fields ( ) {
223
226
check_assist (
224
- extract_struct_from_enum ,
227
+ extract_struct_from_enum_variant ,
225
228
"enum A { <|>One(u32, u32) }" ,
226
229
r#"struct One(pub u32, pub u32);
227
230
@@ -232,7 +235,7 @@ enum A { One(One) }"#,
232
235
#[ test]
233
236
fn test_extract_struct_one_field ( ) {
234
237
check_assist (
235
- extract_struct_from_enum ,
238
+ extract_struct_from_enum_variant ,
236
239
"enum A { <|>One(u32) }" ,
237
240
r#"struct One(pub u32);
238
241
@@ -243,7 +246,7 @@ enum A { One(One) }"#,
243
246
#[ test]
244
247
fn test_extract_struct_pub_visibility ( ) {
245
248
check_assist (
246
- extract_struct_from_enum ,
249
+ extract_struct_from_enum_variant ,
247
250
"pub enum A { <|>One(u32, u32) }" ,
248
251
r#"pub struct One(pub u32, pub u32);
249
252
@@ -254,7 +257,7 @@ pub enum A { One(One) }"#,
254
257
#[ test]
255
258
fn test_extract_struct_with_complex_imports ( ) {
256
259
check_assist (
257
- extract_struct_from_enum ,
260
+ extract_struct_from_enum_variant ,
258
261
r#"mod my_mod {
259
262
fn another_fn() {
260
263
let m = my_other_mod::MyEnum::MyField(1, 1);
@@ -305,7 +308,7 @@ fn another_fn() {
305
308
fn check_not_applicable ( ra_fixture : & str ) {
306
309
let fixture =
307
310
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)
309
312
}
310
313
311
314
#[ test]
0 commit comments