mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Complete enum variants identically to structures.
In particular: - unit variants now display in the menu as "Variant", complete to "Variant", and display a detail of "Variant" (was "()") - tuple variants now display in the menu as "Variant(…)", complete to "Variant(${1:()})$0" (was "Variant($0)"), and display a detail of "Variant(type)" (was "(type)") - record variants now display in the menu as "Variant {…}", complete to "Variant { x: ${1:()} }$0" (was "Variant"), and display a detail of "Variant { x: type }" (was "{x: type}") This behavior is identical to that of struct completions. In addition, tuple variants no longer set triggers_call_info, as to my understanding it's unnecessary now that we're emitting placeholders. Tests have been updated to match, and the render::enum_variant::tests::inserts_parens_for_tuple_enums test has been removed entirely as it's covered by other tests (render::enum_detail_includes_{record, tuple}_fields, render::enum_detail_just_name_for_unit, render::pattern::enum_qualified).
This commit is contained in:
parent
1c5b2c7d03
commit
2a22cf8efc
7 changed files with 69 additions and 90 deletions
|
@ -61,7 +61,7 @@ fn baz() {
|
|||
fn function() fn()
|
||||
sc STATIC
|
||||
un Union
|
||||
ev TupleV(…) (u32)
|
||||
ev TupleV(…) TupleV(u32)
|
||||
ct CONST
|
||||
"#]],
|
||||
)
|
||||
|
@ -171,7 +171,7 @@ impl Unit {
|
|||
fn function() fn()
|
||||
sc STATIC
|
||||
un Union
|
||||
ev TupleV(…) (u32)
|
||||
ev TupleV(…) TupleV(u32)
|
||||
ct CONST
|
||||
"#]],
|
||||
);
|
||||
|
@ -200,7 +200,7 @@ impl Unit {
|
|||
fn function() fn()
|
||||
sc STATIC
|
||||
un Union
|
||||
ev TupleV(…) (u32)
|
||||
ev TupleV(…) TupleV(u32)
|
||||
ct CONST
|
||||
"#]],
|
||||
);
|
||||
|
@ -543,9 +543,9 @@ fn func() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
ev TupleV(…) (u32)
|
||||
ev RecordV {field: u32}
|
||||
ev UnitV ()
|
||||
ev TupleV(…) TupleV(u32)
|
||||
ev RecordV {…} RecordV { field: u32 }
|
||||
ev UnitV UnitV
|
||||
ct ASSOC_CONST const ASSOC_CONST: ()
|
||||
fn assoc_fn() fn()
|
||||
ta AssocType type AssocType = ()
|
||||
|
|
|
@ -218,7 +218,7 @@ fn foo() {
|
|||
expect![[r#"
|
||||
kw ref
|
||||
kw mut
|
||||
ev E::X ()
|
||||
ev E::X E::X
|
||||
en E
|
||||
ma m!(…) macro_rules! m
|
||||
"#]],
|
||||
|
@ -291,9 +291,9 @@ fn func() {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
ev TupleV(…) (u32)
|
||||
ev RecordV {field: u32}
|
||||
ev UnitV ()
|
||||
ev TupleV(…) TupleV(u32)
|
||||
ev RecordV {…} RecordV { field: u32 }
|
||||
ev UnitV UnitV
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ impl Foo {
|
|||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
ev Variant ()
|
||||
ev Variant Variant
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue