Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
// catch `repr()` with no arguments, applied to an item (i.e. not `#![repr()]`)
if item.is_some() {
match target {
Target::Struct | Target::Union | Target::Enum => {}
Target::Struct | Target::Union | Target::Enum => continue,
Target::Fn | Target::Method(_) => {
feature_err(
&self.tcx.sess,
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/repr/repr-empty-packed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ compile-flags: --crate-type=lib
#![deny(unused_attributes)]

#[repr()] //~ ERROR unused attribute
#[repr(packed)] //~ ERROR attribute should be applied to a struct or union
pub enum Foo {
Bar,
Baz(i32),
}
27 changes: 27 additions & 0 deletions tests/ui/repr/repr-empty-packed.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error: unused attribute
--> $DIR/repr-empty-packed.rs:4:1
|
LL | #[repr()]
| ^^^^^^^^^ help: remove this attribute
|
= note: attribute `repr` with an empty list has no effect
note: the lint level is defined here
--> $DIR/repr-empty-packed.rs:2:9
|
LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^

error[E0517]: attribute should be applied to a struct or union
--> $DIR/repr-empty-packed.rs:5:8
|
LL | #[repr(packed)]
| ^^^^^^
LL | / pub enum Foo {
LL | | Bar,
LL | | Baz(i32),
LL | | }
| |_- not a struct or union

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0517`.
Loading