Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The behavior of the Self type in the Extract struct from enum variant option is not as expected #16197

Closed
A4-Tacks opened this issue Dec 26, 2023 · 1 comment · Fixed by #16199
Assignees
Labels
C-bug Category: bug

Comments

@A4-Tacks
Copy link

A4-Tacks commented Dec 26, 2023

The behavior of the Self type in the Extract struct from enum variant option is not as expected

Source code

enum Foo {
    Bar { node: Box<Self> },
    Nil,
}

fn main() {}

in line2 column5 use Extract struct from enum variant

struct Bar{ node: Box<Self> }

enum Foo {
    Bar(Bar),
    Nil,
}

fn main() {}

Expected

struct Bar { node: Box<Foo> }

enum Foo {
    Bar(Bar),
    Nil,
}

fn main() {}

rust-analyzer version: rust-analyzer 1.74.0 (79e9716c 2023-11-13) or rust-analyzer 1.77.0-nightly (bf8716f1 2023-12-24)

rustc version: rustc 1.74.0 (79e9716c9 2023-11-13) or rustc 1.77.0-nightly (bf8716f1c 2023-12-24)

relevant settings: NONE

@A4-Tacks A4-Tacks added the C-bug Category: bug label Dec 26, 2023
@Young-Flash
Copy link
Member

should check GenericArg at

fn extract_field_list_if_applicable(
variant: &ast::Variant,
) -> Option<Either<ast::RecordFieldList, ast::TupleFieldList>> {
match variant.kind() {
ast::StructKind::Record(field_list) if field_list.fields().next().is_some() => {
Some(Either::Left(field_list))
}

I'll take a try, @rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
2 participants