about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/liballoc/tests/lib.rs1
-rw-r--r--src/libstd/lib.rs2
-rw-r--r--src/libsyntax/feature_gate.rs30
-rw-r--r--src/test/codegen/align-struct.rs3
-rw-r--r--src/test/compile-fail/conflicting-repr-hints.rs2
-rw-r--r--src/test/compile-fail/repr-align.rs2
-rw-r--r--src/test/compile-fail/repr-packed-contains-align.rs2
-rw-r--r--src/test/run-pass/align-struct.rs2
-rw-r--r--src/test/run-pass/union/union-align.rs2
-rw-r--r--src/test/ui/feature-gate-repr_align.rs15
-rw-r--r--src/test/ui/feature-gate-repr_align.stderr10
-rw-r--r--src/test/ui/print_type_sizes/repr-align.rs2
-rw-r--r--src/test/ui/span/gated-features-attr-spans.rs2
-rw-r--r--src/test/ui/span/gated-features-attr-spans.stderr10
14 files changed, 20 insertions, 65 deletions
diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs
index eee229bc6fd..427a7adcbde 100644
--- a/src/liballoc/tests/lib.rs
+++ b/src/liballoc/tests/lib.rs
@@ -23,7 +23,6 @@
 #![feature(pattern)]
 #![feature(placement_in_syntax)]
 #![feature(rand)]
-#![feature(repr_align)]
 #![feature(slice_rotate)]
 #![feature(splice)]
 #![feature(str_escape)]
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 91cc6d25cce..a8049e676b3 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -296,7 +296,6 @@
 #![feature(ptr_internals)]
 #![feature(rand)]
 #![feature(raw)]
-#![feature(repr_align)]
 #![feature(rustc_attrs)]
 #![feature(sip_hash_13)]
 #![feature(slice_bytes)]
@@ -323,6 +322,7 @@
 #![feature(doc_spotlight)]
 #![cfg_attr(test, feature(update_panic_count))]
 #![cfg_attr(windows, feature(used))]
+#![cfg_attr(stage0, feature(repr_align))]
 
 #![default_lib_allocator]
 
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index ac5a10ec703..5a7b53153fd 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -343,9 +343,6 @@ declare_features! (
     // Allows the `catch {...}` expression
     (active, catch_expr, "1.17.0", Some(31436)),
 
-    // Allows `repr(align(u16))` struct attribute (RFC 1358)
-    (active, repr_align, "1.17.0", Some(33626)),
-
     // Used to preserve symbols (see llvm.used)
     (active, used, "1.18.0", Some(40289)),
 
@@ -546,6 +543,8 @@ declare_features! (
     // Allows the sysV64 ABI to be specified on all platforms
     // instead of just the platforms on which it is the C ABI
     (accepted, abi_sysv64, "1.24.0", Some(36167)),
+    // Allows `repr(align(16))` struct attribute (RFC 1358)
+    (accepted, repr_align, "1.24.0", Some(33626)),
 );
 
 // If you change this, please modify src/doc/unstable-book as well. You must
@@ -1456,15 +1455,25 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
             }
         }
 
+        // allow attr_literals in #[repr(align(x))]
+        let mut is_repr_align = false;
+        if attr.path == "repr" {
+            if let Some(content) = attr.meta_item_list() {
+                is_repr_align = content.iter().any(|c| c.check_name("align"));
+            }
+        }
+
         if self.context.features.proc_macro && attr::is_known(attr) {
             return
         }
 
-        let meta = panictry!(attr.parse_meta(self.context.parse_sess));
-        if contains_novel_literal(&meta) {
-            gate_feature_post!(&self, attr_literals, attr.span,
-                               "non-string literals in attributes, or string \
-                               literals in top-level positions, are experimental");
+        if !is_repr_align {
+            let meta = panictry!(attr.parse_meta(self.context.parse_sess));
+            if contains_novel_literal(&meta) {
+                gate_feature_post!(&self, attr_literals, attr.span,
+                                   "non-string literals in attributes, or string \
+                                   literals in top-level positions, are experimental");
+            }
         }
     }
 
@@ -1522,11 +1531,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
                             gate_feature_post!(&self, repr_simd, attr.span,
                                                "SIMD types are experimental and possibly buggy");
                         }
-                        if item.check_name("align") {
-                            gate_feature_post!(&self, repr_align, attr.span,
-                                               "the struct `#[repr(align(u16))]` attribute \
-                                                is experimental");
-                        }
                         if item.check_name("transparent") {
                             gate_feature_post!(&self, repr_transparent, attr.span,
                                                "the `#[repr(transparent)]` attribute \
diff --git a/src/test/codegen/align-struct.rs b/src/test/codegen/align-struct.rs
index ab9f5dda3a1..155319cb154 100644
--- a/src/test/codegen/align-struct.rs
+++ b/src/test/codegen/align-struct.rs
@@ -13,9 +13,6 @@
 
 #![crate_type = "lib"]
 
-#![feature(attr_literals)]
-#![feature(repr_align)]
-
 #[repr(align(64))]
 pub struct Align64(i32);
 // CHECK: %Align64 = type { [0 x i32], i32, [15 x i32] }
diff --git a/src/test/compile-fail/conflicting-repr-hints.rs b/src/test/compile-fail/conflicting-repr-hints.rs
index 12ac8fb57b1..8acc8b7bb1e 100644
--- a/src/test/compile-fail/conflicting-repr-hints.rs
+++ b/src/test/compile-fail/conflicting-repr-hints.rs
@@ -9,8 +9,6 @@
 // except according to those terms.
 
 #![allow(dead_code)]
-#![feature(attr_literals)]
-#![feature(repr_align)]
 
 #[repr(C)]
 enum A { A }
diff --git a/src/test/compile-fail/repr-align.rs b/src/test/compile-fail/repr-align.rs
index bc9cf065e5a..7c8eb6a2de9 100644
--- a/src/test/compile-fail/repr-align.rs
+++ b/src/test/compile-fail/repr-align.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 #![allow(dead_code)]
-#![feature(attr_literals)]
-#![feature(repr_align)]
 
 #[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer
 struct A(i32);
diff --git a/src/test/compile-fail/repr-packed-contains-align.rs b/src/test/compile-fail/repr-packed-contains-align.rs
index 78d43064ea3..27890333a51 100644
--- a/src/test/compile-fail/repr-packed-contains-align.rs
+++ b/src/test/compile-fail/repr-packed-contains-align.rs
@@ -7,8 +7,6 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
-#![feature(attr_literals)]
-#![feature(repr_align)]
 #![feature(untagged_unions)]
 #![allow(dead_code)]
 
diff --git a/src/test/run-pass/align-struct.rs b/src/test/run-pass/align-struct.rs
index e42aa868c47..dea8462705f 100644
--- a/src/test/run-pass/align-struct.rs
+++ b/src/test/run-pass/align-struct.rs
@@ -7,8 +7,6 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
-#![feature(attr_literals)]
-#![feature(repr_align)]
 #![feature(box_syntax)]
 
 use std::mem;
diff --git a/src/test/run-pass/union/union-align.rs b/src/test/run-pass/union/union-align.rs
index c0100df53e7..54e4e12d24f 100644
--- a/src/test/run-pass/union/union-align.rs
+++ b/src/test/run-pass/union/union-align.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(attr_literals)]
-#![feature(repr_align)]
 #![feature(untagged_unions)]
 
 use std::mem::{size_of, size_of_val, align_of, align_of_val};
diff --git a/src/test/ui/feature-gate-repr_align.rs b/src/test/ui/feature-gate-repr_align.rs
deleted file mode 100644
index 9591d367a2d..00000000000
--- a/src/test/ui/feature-gate-repr_align.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-#![feature(attr_literals)]
-
-#[repr(align(64))] //~ error: the struct `#[repr(align(u16))]` attribute is experimental
-struct Foo(u64, u64);
-
-fn main() {}
diff --git a/src/test/ui/feature-gate-repr_align.stderr b/src/test/ui/feature-gate-repr_align.stderr
deleted file mode 100644
index dd88067d58f..00000000000
--- a/src/test/ui/feature-gate-repr_align.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error[E0658]: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
-  --> $DIR/feature-gate-repr_align.rs:12:1
-   |
-12 | #[repr(align(64))] //~ error: the struct `#[repr(align(u16))]` attribute is experimental
-   | ^^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(repr_align)] to the crate attributes to enable
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/print_type_sizes/repr-align.rs b/src/test/ui/print_type_sizes/repr-align.rs
index 108b8dbba01..92928bba1c3 100644
--- a/src/test/ui/print_type_sizes/repr-align.rs
+++ b/src/test/ui/print_type_sizes/repr-align.rs
@@ -18,8 +18,6 @@
 // It avoids using u64/i64 because on some targets that is only 4-byte
 // aligned (while on most it is 8-byte aligned) and so the resulting
 // padding and overall computed sizes can be quite different.
-#![feature(attr_literals)]
-#![feature(repr_align)]
 #![feature(start)]
 #![allow(dead_code)]
 
diff --git a/src/test/ui/span/gated-features-attr-spans.rs b/src/test/ui/span/gated-features-attr-spans.rs
index ace185d0169..83a4c5d5dd2 100644
--- a/src/test/ui/span/gated-features-attr-spans.rs
+++ b/src/test/ui/span/gated-features-attr-spans.rs
@@ -10,7 +10,7 @@
 
 #![feature(attr_literals)]
 
-#[repr(align(16))] //~ ERROR is experimental
+#[repr(align(16))]
 struct Gem {
     mohs_hardness: u8,
     poofed: bool,
diff --git a/src/test/ui/span/gated-features-attr-spans.stderr b/src/test/ui/span/gated-features-attr-spans.stderr
index 74a2c1d742b..f15c4a72c5a 100644
--- a/src/test/ui/span/gated-features-attr-spans.stderr
+++ b/src/test/ui/span/gated-features-attr-spans.stderr
@@ -1,11 +1,3 @@
-error[E0658]: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
-  --> $DIR/gated-features-attr-spans.rs:13:1
-   |
-13 | #[repr(align(16))] //~ ERROR is experimental
-   | ^^^^^^^^^^^^^^^^^^
-   |
-   = help: add #![feature(repr_align)] to the crate attributes to enable
-
 error[E0658]: SIMD types are experimental and possibly buggy (see issue #27731)
   --> $DIR/gated-features-attr-spans.rs:20:1
    |
@@ -30,5 +22,5 @@ warning: `#[must_use]` on functions is experimental (see issue #43302)
    |
    = help: add #![feature(fn_must_use)] to the crate attributes to enable
 
-error: aborting due to 2 previous errors
+error: aborting due to previous error