Skip to content

E0084 and E0517 should show both repr attribute and struct #45886

Closed
@Havvy

Description

@Havvy

You can trigger both errors by using #[repr(packed)] on an enum with no variants.

#[repr(packed)]
enum Void {}

The errors given out are:

   Compiling playground v0.0.1 (file:///playground)
error[E0517]: attribute should be applied to struct or union
 --> src/main.rs:1:1
  |
1 | #[repr(packed)]
  | ^^^^^^^^^^^^^^^ requires a struct or union

error[E0084]: unsupported representation for zero-variant enum
 --> src/main.rs:2:1
  |
2 | enum Void {}
  | ^^^^^^^^^^^^ unsupported enum representation

error: aborting due to 2 previous errors

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

E0517 shows the attribute, but does not show the enum. E0084 shows the enum, but does not show the attribute. Both errors should show both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions