Skip to content

Commit 733d3ac

Browse files
authored
Rollup merge of rust-lang#74109 - nbdd0121:issue-74082, r=petrochenkov
Only allow `repr(i128/u128)` on enum Fixes rust-lang#74082
2 parents bed8cf6 + 97867bb commit 733d3ac

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/librustc_passes/check_attr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ impl CheckAttrVisitor<'tcx> {
292292
| sym::u32
293293
| sym::i64
294294
| sym::u64
295+
| sym::i128
296+
| sym::u128
295297
| sym::isize
296298
| sym::usize => {
297299
int_reprs += 1;

src/test/ui/issues/issue-74082.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![allow(dead_code)]
2+
3+
#[repr(i128)] //~ ERROR: attribute should be applied to enum
4+
struct Foo;
5+
6+
#[repr(u128)] //~ ERROR: attribute should be applied to enum
7+
struct Bar;
8+
9+
fn main() {}

src/test/ui/issues/issue-74082.stderr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0517]: attribute should be applied to enum
2+
--> $DIR/issue-74082.rs:3:8
3+
|
4+
LL | #[repr(i128)]
5+
| ^^^^
6+
LL | struct Foo;
7+
| ----------- not an enum
8+
9+
error[E0517]: attribute should be applied to enum
10+
--> $DIR/issue-74082.rs:6:8
11+
|
12+
LL | #[repr(u128)]
13+
| ^^^^
14+
LL | struct Bar;
15+
| ----------- not an enum
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0517`.

0 commit comments

Comments
 (0)