Skip to content

Commit a6d3c77

Browse files
committed
Fixed tests
1 parent eefa10b commit a6d3c77

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use ra_db::FileId;
1818
use ra_fmt::leading_indent;
1919
use 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]

crates/ra_assists/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ mod handlers {
156156
change_return_type_to_result::change_return_type_to_result,
157157
change_visibility::change_visibility,
158158
early_return::convert_to_guarded_return,
159-
extract_struct_from_enum_variant::extract_struct_from_enum,
159+
extract_struct_from_enum_variant::extract_struct_from_enum_variant,
160160
fill_match_arms::fill_match_arms,
161161
fix_visibility::fix_visibility,
162162
flip_binexpr::flip_binexpr,

crates/ra_assists/src/tests/generated.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,21 @@ fn main() {
337337
)
338338
}
339339

340+
#[test]
341+
fn doctest_extract_struct_from_enum_variant() {
342+
check_doc_test(
343+
"extract_struct_from_enum_variant",
344+
r#####"
345+
enum A { <|>One(u32, u32) }
346+
"#####,
347+
r#####"
348+
struct One(pub u32, pub u32);
349+
350+
enum A { One(One) }
351+
"#####,
352+
)
353+
}
354+
340355
#[test]
341356
fn doctest_fill_match_arms() {
342357
check_doc_test(

0 commit comments

Comments
 (0)