Skip to content

Commit

Permalink
Rollup merge of #74109 - nbdd0121:issue-74082, r=petrochenkov
Browse files Browse the repository at this point in the history
Only allow `repr(i128/u128)` on enum

Fixes #74082
  • Loading branch information
Manishearth authored Jul 11, 2020
2 parents fa50a87 + 97867bb commit 8efa197
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/librustc_passes/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ impl CheckAttrVisitor<'tcx> {
| sym::u32
| sym::i64
| sym::u64
| sym::i128
| sym::u128
| sym::isize
| sym::usize => {
int_reprs += 1;
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/issues/issue-74082.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![allow(dead_code)]

#[repr(i128)] //~ ERROR: attribute should be applied to enum
struct Foo;

#[repr(u128)] //~ ERROR: attribute should be applied to enum
struct Bar;

fn main() {}
19 changes: 19 additions & 0 deletions src/test/ui/issues/issue-74082.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0517]: attribute should be applied to enum
--> $DIR/issue-74082.rs:3:8
|
LL | #[repr(i128)]
| ^^^^
LL | struct Foo;
| ----------- not an enum

error[E0517]: attribute should be applied to enum
--> $DIR/issue-74082.rs:6:8
|
LL | #[repr(u128)]
| ^^^^
LL | struct Bar;
| ----------- not an enum

error: aborting due to 2 previous errors

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

0 comments on commit 8efa197

Please sign in to comment.