Skip to content

Commit

Permalink
Unrolled build for rust-lang#135219
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#135219 - matthiaskrgr:simd'nt, r=compiler-errors

warn about broken simd not only on structs but also enums and unions when we didn't opt in to it

addresses rust-lang#135208 (comment)

r? ``@Noratrieb``
  • Loading branch information
rust-timer authored Jan 8, 2025
2 parents 1f81f90 + b9d6e9e commit da0a0b5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}
}

ast::ItemKind::Struct(..) => {
ast::ItemKind::Struct(..) | ast::ItemKind::Enum(..) | ast::ItemKind::Union(..) => {
for attr in attr::filter_by_name(&i.attrs, sym::repr) {
for item in attr.meta_item_list().unwrap_or_else(ThinVec::new) {
if item.has_name(sym::simd) {
Expand Down
12 changes: 10 additions & 2 deletions tests/ui/feature-gates/feature-gate-repr-simd.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#[repr(simd)] //~ error: SIMD types are experimental
#[repr(simd)] //~ ERROR: SIMD types are experimental
struct Foo([u64; 2]);

#[repr(C)] //~ ERROR conflicting representation hints
//~^ WARN this was previously accepted
#[repr(simd)] //~ error: SIMD types are experimental
#[repr(simd)] //~ ERROR: SIMD types are experimental
struct Bar([u64; 2]);

#[repr(simd)] //~ ERROR: SIMD types are experimental
//~^ ERROR: attribute should be applied to a struct
union U {f: u32}

#[repr(simd)] //~ ERROR: SIMD types are experimental
//~^ error: attribute should be applied to a struct
enum E { X }

fn main() {}
44 changes: 41 additions & 3 deletions tests/ui/feature-gates/feature-gate-repr-simd.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ LL | #[repr(simd)]
= help: add `#![feature(repr_simd)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: SIMD types are experimental and possibly buggy
--> $DIR/feature-gate-repr-simd.rs:9:1
|
LL | #[repr(simd)]
| ^^^^^^^^^^^^^
|
= note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information
= help: add `#![feature(repr_simd)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: SIMD types are experimental and possibly buggy
--> $DIR/feature-gate-repr-simd.rs:13:1
|
LL | #[repr(simd)]
| ^^^^^^^^^^^^^
|
= note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information
= help: add `#![feature(repr_simd)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0566]: conflicting representation hints
--> $DIR/feature-gate-repr-simd.rs:4:8
|
Expand All @@ -31,10 +51,28 @@ LL | #[repr(simd)]
= note: for more information, see issue #68585 <https://github.com/rust-lang/rust/issues/68585>
= note: `#[deny(conflicting_repr_hints)]` on by default

error: aborting due to 3 previous errors
error[E0517]: attribute should be applied to a struct
--> $DIR/feature-gate-repr-simd.rs:9:8
|
LL | #[repr(simd)]
| ^^^^
LL |
LL | union U {f: u32}
| ---------------- not a struct

error[E0517]: attribute should be applied to a struct
--> $DIR/feature-gate-repr-simd.rs:13:8
|
LL | #[repr(simd)]
| ^^^^
LL |
LL | enum E { X }
| ------------ not a struct

error: aborting due to 7 previous errors

Some errors have detailed explanations: E0566, E0658.
For more information about an error, try `rustc --explain E0566`.
Some errors have detailed explanations: E0517, E0566, E0658.
For more information about an error, try `rustc --explain E0517`.
Future incompatibility report: Future breakage diagnostic:
error[E0566]: conflicting representation hints
--> $DIR/feature-gate-repr-simd.rs:4:8
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/repr/issue-83505-repr-simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#[repr(simd)]
//~^ ERROR: attribute should be applied to a struct [E0517]
//~| ERROR: unsupported representation for zero-variant enum [E0084]
//~| ERROR: SIMD types are experimental and possibly buggy [E0658]

enum Es {}
static CLs: Es;
//~^ ERROR: free static item without body
16 changes: 13 additions & 3 deletions tests/ui/repr/issue-83505-repr-simd.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
error: free static item without body
--> $DIR/issue-83505-repr-simd.rs:9:1
--> $DIR/issue-83505-repr-simd.rs:11:1
|
LL | static CLs: Es;
| ^^^^^^^^^^^^^^-
| |
| help: provide a definition for the static: `= <expr>;`

error[E0658]: SIMD types are experimental and possibly buggy
--> $DIR/issue-83505-repr-simd.rs:5:1
|
LL | #[repr(simd)]
| ^^^^^^^^^^^^^
|
= note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information
= help: add `#![feature(repr_simd)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0517]: attribute should be applied to a struct
--> $DIR/issue-83505-repr-simd.rs:5:8
|
Expand All @@ -24,7 +34,7 @@ LL | #[repr(simd)]
LL | enum Es {}
| ------- zero-variant enum

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0084, E0517.
Some errors have detailed explanations: E0084, E0517, E0658.
For more information about an error, try `rustc --explain E0084`.

0 comments on commit da0a0b5

Please sign in to comment.