Skip to content

Commit

Permalink
Add feature gate for Scalable SIMD types
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieCunliffe committed Nov 23, 2023
1 parent 4c14a6d commit 28b752a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
"SIMD types are experimental and possibly buggy"
);
}

if item.has_name(sym::scalable) {
gate!(
&self,
repr_scalable,
attr.span,
"Scalable SIMD types are experimental and possibly buggy"
);
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ declare_features! (
(internal, prelude_import, "1.2.0", None, None),
/// Used to identify crates that contain the profiler runtime.
(internal, profiler_runtime, "1.18.0", None, None),
/// Allows the use of scalable SIMD types.
(unstable, repr_scalable, "CURRENT_RUSTC_VERSION", None, None),
/// Allows using `rustc_*` attributes (RFC 572).
(internal, rustc_attrs, "1.0.0", None, None),
/// Allows using the `#[stable]` and `#[unstable]` attributes.
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/feature-gates/feature-gate-repr-scalable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(repr_simd)]

#[repr(simd, scalable(16))] //~ error: Scalable SIMD types are experimental
struct Foo {
_ty: [i8; 0],
}

fn main() {}
11 changes: 11 additions & 0 deletions tests/ui/feature-gates/feature-gate-repr-scalable.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0658]: Scalable SIMD types are experimental and possibly buggy
--> $DIR/feature-gate-repr-scalable.rs:3:1
|
LL | #[repr(simd, scalable(16))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(repr_scalable)]` to the crate attributes to enable

error: aborting due to previous error

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

0 comments on commit 28b752a

Please sign in to comment.