diff --git a/src/doc/unstable-book/src/language-features/repr-align-enum.md b/src/doc/unstable-book/src/language-features/repr-align-enum.md deleted file mode 100644 index 415c6ebe8b4bc..0000000000000 --- a/src/doc/unstable-book/src/language-features/repr-align-enum.md +++ /dev/null @@ -1,42 +0,0 @@ -# `repr_align_enum` - -The tracking issue for this feature is: [#57996] - -[#57996]: https://github.com/rust-lang/rust/issues/57996 - ------------------------- - -The `repr_align_enum` feature allows using the `#[repr(align(x))]` attribute -on enums, similarly to structs. - -# Examples - -```rust -#![feature(repr_align_enum)] - -#[repr(align(8))] -enum Aligned { - Foo, - Bar { value: u32 }, -} - -fn main() { - assert_eq!(std::mem::align_of::(), 8); -} -``` - -This is equivalent to using an aligned wrapper struct everywhere: - -```rust -#[repr(align(8))] -struct Aligned(Unaligned); - -enum Unaligned { - Foo, - Bar { value: u32 }, -} - -fn main() { - assert_eq!(std::mem::align_of::(), 8); -} -``` diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 6a049b80acae2..cebddbc556e2e 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -548,9 +548,6 @@ declare_features! ( // Allows using `#[optimize(X)]`. (active, optimize_attribute, "1.34.0", Some(54882), None), - // Allows using `#[repr(align(X))]` on enums. - (active, repr_align_enum, "1.34.0", Some(57996), None), - // Allows using C-variadics. (active, c_variadic, "1.34.0", Some(44930), None), @@ -833,6 +830,9 @@ declare_features! ( (accepted, extern_crate_self, "1.34.0", Some(56409), None), // Allows arbitrary delimited token streams in non-macro attributes. (accepted, unrestricted_attribute_tokens, "1.34.0", Some(55208), None), + // Allows using `#[repr(align(X))]` on enums with equivalent semantics + // to wrapping an enum in a wrapper struct with `#[repr(align(X))]`. + (accepted, repr_align_enum, "1.37.0", Some(57996), None), // ------------------------------------------------------------------------- // feature-group-end: accepted features @@ -1995,17 +1995,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } - ast::ItemKind::Enum(..) => { - for attr in attr::filter_by_name(&i.attrs[..], sym::repr) { - for item in attr.meta_item_list().unwrap_or_else(Vec::new) { - if item.check_name(sym::align) { - gate_feature_post!(&self, repr_align_enum, attr.span, - "`#[repr(align(x))]` on enums is experimental"); - } - } - } - } - ast::ItemKind::Impl(_, polarity, defaultness, _, _, _, _) => { if polarity == ast::ImplPolarity::Negative { gate_feature_post!(&self, optin_builtin_traits, diff --git a/src/test/codegen/align-enum.rs b/src/test/codegen/align-enum.rs index 2251c54229ee0..4241fcea8047d 100644 --- a/src/test/codegen/align-enum.rs +++ b/src/test/codegen/align-enum.rs @@ -3,7 +3,6 @@ // min-llvm-version 7.0 #![crate_type = "lib"] -#![feature(repr_align_enum)] #[repr(align(64))] pub enum Align64 { diff --git a/src/test/run-pass/structs-enums/align-enum.rs b/src/test/run-pass/structs-enums/align-enum.rs index 8d72b1f6f0d24..fa872caa3b47e 100644 --- a/src/test/run-pass/structs-enums/align-enum.rs +++ b/src/test/run-pass/structs-enums/align-enum.rs @@ -1,6 +1,5 @@ // run-pass #![allow(dead_code)] -#![feature(repr_align_enum)] use std::mem; diff --git a/src/test/ui/attr-usage-repr.rs b/src/test/ui/attr-usage-repr.rs index 1df2947cbe2dd..ef64dfe20bc9d 100644 --- a/src/test/ui/attr-usage-repr.rs +++ b/src/test/ui/attr-usage-repr.rs @@ -1,5 +1,4 @@ #![feature(repr_simd)] -#![feature(repr_align_enum)] #[repr(C)] //~ ERROR: attribute should be applied to struct, enum or union fn f() {} diff --git a/src/test/ui/attr-usage-repr.stderr b/src/test/ui/attr-usage-repr.stderr index f8ad7eec454c4..d1f4f3bfeb2cb 100644 --- a/src/test/ui/attr-usage-repr.stderr +++ b/src/test/ui/attr-usage-repr.stderr @@ -1,5 +1,5 @@ error[E0517]: attribute should be applied to struct, enum or union - --> $DIR/attr-usage-repr.rs:4:8 + --> $DIR/attr-usage-repr.rs:3:8 | LL | #[repr(C)] | ^ @@ -7,7 +7,7 @@ LL | fn f() {} | --------- not a struct, enum or union error[E0517]: attribute should be applied to enum - --> $DIR/attr-usage-repr.rs:16:8 + --> $DIR/attr-usage-repr.rs:15:8 | LL | #[repr(i8)] | ^^ @@ -15,7 +15,7 @@ LL | struct SInt(f64, f64); | ---------------------- not an enum error[E0517]: attribute should be applied to struct or union - --> $DIR/attr-usage-repr.rs:25:8 + --> $DIR/attr-usage-repr.rs:24:8 | LL | #[repr(packed)] | ^^^^^^ @@ -23,7 +23,7 @@ LL | enum EPacked { A, B } | --------------------- not a struct or union error[E0517]: attribute should be applied to struct - --> $DIR/attr-usage-repr.rs:28:8 + --> $DIR/attr-usage-repr.rs:27:8 | LL | #[repr(simd)] | ^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-repr_align_enum.rs b/src/test/ui/feature-gates/feature-gate-repr_align_enum.rs deleted file mode 100644 index 8b68caa6f5b0e..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-repr_align_enum.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[repr(align(16))] -struct Foo(u64); - -#[repr(align(8))] //~ ERROR `#[repr(align(x))]` on enums is experimental -enum Bar { - Foo { foo: Foo }, - Baz, -} - -fn main() { } diff --git a/src/test/ui/feature-gates/feature-gate-repr_align_enum.stderr b/src/test/ui/feature-gates/feature-gate-repr_align_enum.stderr deleted file mode 100644 index 36924f4c167ca..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-repr_align_enum.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: `#[repr(align(x))]` on enums is experimental - --> $DIR/feature-gate-repr_align_enum.rs:4:1 - | -LL | #[repr(align(8))] - | ^^^^^^^^^^^^^^^^^ - | - = note: for more information, see https://github.com/rust-lang/rust/issues/57996 - = help: add #![feature(repr_align_enum)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/repr/repr-align.rs b/src/test/ui/repr/repr-align.rs index 9ce89e82ca225..2e90360aff2f1 100644 --- a/src/test/ui/repr/repr-align.rs +++ b/src/test/ui/repr/repr-align.rs @@ -1,4 +1,3 @@ -#![feature(repr_align_enum)] #![allow(dead_code)] #[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer diff --git a/src/test/ui/repr/repr-align.stderr b/src/test/ui/repr/repr-align.stderr index 641f117a71710..645ed0c8ad3b1 100644 --- a/src/test/ui/repr/repr-align.stderr +++ b/src/test/ui/repr/repr-align.stderr @@ -1,23 +1,23 @@ error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer - --> $DIR/repr-align.rs:4:8 + --> $DIR/repr-align.rs:3:8 | LL | #[repr(align(16.0))] | ^^^^^^^^^^^ error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:7:8 + --> $DIR/repr-align.rs:6:8 | LL | #[repr(align(15))] | ^^^^^^^^^ error[E0589]: invalid `repr(align)` attribute: larger than 2^29 - --> $DIR/repr-align.rs:10:8 + --> $DIR/repr-align.rs:9:8 | LL | #[repr(align(4294967296))] | ^^^^^^^^^^^^^^^^^ error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:16:8 + --> $DIR/repr-align.rs:15:8 | LL | #[repr(align(15))] | ^^^^^^^^^