Skip to content

'Generate enum variant' ignores data signature #12797

Closed
@sclu1034

Description

@sclu1034

Actual behaviour:

enum Foo {
	Foo(bool),
}

fn foo() {
	let bar = Foo::Bar(true);
}

Attempting to run the 'Generate variant' code action on Foo::Bar(true) will ignore the attached data and generate this:

enum Foo {
	Foo(bool),
	Bar,
}

Expected behaviour:

'Generate variant' adds the appropriate type signature for the variant's data (Bar(bool) in this case). The same should happen for inline structs (e.g. Bar { bar: bool }).

Additionally, I think 'Generate method' (presumably what was disabled in #12334) would also make sense as a second option, with the parenthesis as a stronger indicator for a method than the PascalCase against it.

rust-analyzer version: (eg. output of "Rust Analyzer: Show RA Version" command)

rust-analyzer 0.4.1130-standalone (897a7ec4b 2022-07-17)

rustc version: (eg. output of rustc -V)

rustc 1.62.0 (a8314ef7d 2022-06-27)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTUP_HOME or CARGO_HOME)

N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions