From 5702e0289f7d19f0ea133d43da7dcd7cbfc5b557 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Mon, 6 Jul 2020 20:42:19 +0100 Subject: [PATCH 1/2] Only allow `repr(i128/u128)` on enum --- src/librustc_passes/check_attr.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_passes/check_attr.rs b/src/librustc_passes/check_attr.rs index ef84f251390e6..fee63b1ee524e 100644 --- a/src/librustc_passes/check_attr.rs +++ b/src/librustc_passes/check_attr.rs @@ -292,6 +292,8 @@ impl CheckAttrVisitor<'tcx> { | sym::u32 | sym::i64 | sym::u64 + | sym::i128 + | sym::u128 | sym::isize | sym::usize => { int_reprs += 1; From 97867bbe5cd09df7754864c826f58d3029f4422e Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Mon, 6 Jul 2020 21:04:54 +0100 Subject: [PATCH 2/2] Add UI test for issue 74082 --- src/test/ui/issues/issue-74082.rs | 9 +++++++++ src/test/ui/issues/issue-74082.stderr | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/test/ui/issues/issue-74082.rs create mode 100644 src/test/ui/issues/issue-74082.stderr diff --git a/src/test/ui/issues/issue-74082.rs b/src/test/ui/issues/issue-74082.rs new file mode 100644 index 0000000000000..982f8ef02538b --- /dev/null +++ b/src/test/ui/issues/issue-74082.rs @@ -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() {} diff --git a/src/test/ui/issues/issue-74082.stderr b/src/test/ui/issues/issue-74082.stderr new file mode 100644 index 0000000000000..08fe415513d0d --- /dev/null +++ b/src/test/ui/issues/issue-74082.stderr @@ -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`.