about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorCameron Hart <cameron.hart@gmail.com>2017-12-26 10:24:23 +1100
committerCameron Hart <cameron.hart@gmail.com>2018-01-23 08:36:13 +1100
commit651ea8ea44d8ac8a02dc357412eb73f830057cae (patch)
tree820d926f0c4be2a27bd66376a1b24bb107f41534 /src/libsyntax
parentfdc18b3067b5bad257ccbe7400e3c4fb617e9e18 (diff)
downloadrust-651ea8ea44d8ac8a02dc357412eb73f830057cae.tar.gz
rust-651ea8ea44d8ac8a02dc357412eb73f830057cae.zip
Stabilized `#[repr(align(x))]` attribute (RFC 1358)
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/feature_gate.rs30
1 files changed, 17 insertions, 13 deletions
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 \