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

analyze: bad rewrite of derive(Clone) on unions #990

Closed
spernsteiner opened this issue Jul 17, 2023 · 0 comments · Fixed by #1012
Closed

analyze: bad rewrite of derive(Clone) on unions #990

spernsteiner opened this issue Jul 17, 2023 · 0 comments · Fixed by #1012
Assignees

Comments

@spernsteiner
Copy link
Collaborator

spernsteiner commented Jul 17, 2023

#[derive(Copy, Clone)]
pub union Foo {
    x: usize,
    y: *mut u8,
}

This gets rewritten to

#[derive(Copy, &Foo)]
pub union Foo {
    x: usize,
    y: *mut u8,
}

Note the derive(Copy, &Foo), which is invalid. This seems related to pointers and/or hypothetical lifetimes, since the issue doesn't occur when all fields of the union are integers like i32.

This looks similar to #952, but might have a different cause, since essentially every part of the derive(Clone) output gets assigned the span of the token Clone.

@aneksteind aneksteind self-assigned this Jul 19, 2023
@aneksteind aneksteind linked a pull request Aug 2, 2023 that will close this issue
aneksteind added a commit that referenced this issue Aug 2, 2023
Adds test showing #995 and #990 are fixed. I believe #1005 and #956
combined fixed these issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants