Skip to content

Commit c8b340e

Browse files
feature: gate repr(scalable) with repr_scalable
Add a `repr_scalable` feature gate and require its use for the `repr(scalable(N)` attribute. Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
1 parent b3494b4 commit c8b340e

File tree

7 files changed

+126
-84
lines changed

7 files changed

+126
-84
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
213213
"SIMD types are experimental and possibly buggy"
214214
);
215215
}
216+
217+
if item.has_name(sym::scalable) {
218+
gate!(
219+
&self,
220+
repr_scalable,
221+
attr.span,
222+
"scalable vector types are experimental"
223+
);
224+
}
216225
}
217226
}
218227
}

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ declare_features! (
235235
(internal, prelude_import, "1.2.0", None),
236236
/// Used to identify crates that contain the profiler runtime.
237237
(internal, profiler_runtime, "1.18.0", None),
238+
/// Allows the use of `repr(scalable)`.
239+
(unstable, repr_scalable, "CURRENT_RUSTC_VERSION", None),
238240
/// Allows using `rustc_*` attributes (RFC 572).
239241
(internal, rustc_attrs, "1.0.0", None),
240242
/// Introduces a hierarchy of `Sized` traits (RFC 3729).

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,7 @@ symbols! {
17641764
repr_align,
17651765
repr_align_enum,
17661766
repr_packed,
1767+
repr_scalable,
17671768
repr_simd,
17681769
repr_transparent,
17691770
require,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(repr_simd)]
2+
3+
#[repr(simd, scalable(16))] //~ ERROR: scalable vector types are experimental
4+
struct Foo { //~ ERROR: SIMD vector's only field must be an array
5+
_ty: [i8],
6+
}
7+
8+
fn main() {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0658]: scalable vector types are experimental
2+
--> $DIR/feature-gate-repr-scalable.rs:3:1
3+
|
4+
LL | #[repr(simd, scalable(16))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add `#![feature(repr_scalable)]` to the crate attributes to enable
8+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
9+
10+
error[E0076]: SIMD vector's only field must be an array
11+
--> $DIR/feature-gate-repr-scalable.rs:4:1
12+
|
13+
LL | struct Foo {
14+
| ^^^^^^^^^^
15+
LL | _ty: [i8],
16+
| --------- not an array
17+
18+
error: aborting due to 2 previous errors
19+
20+
Some errors have detailed explanations: E0076, E0658.
21+
For more information about an error, try `rustc --explain E0076`.

tests/ui/simd/scalable/invalid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(internal_features, unused_imports, unused_macros)]
33
#![feature(extern_types)]
44
#![feature(gen_blocks)]
5+
#![feature(repr_scalable)]
56
#![feature(repr_simd)]
67
#![feature(stmt_expr_attributes)]
78
#![feature(trait_alias)]

0 commit comments

Comments
 (0)