From 651ea8ea44d8ac8a02dc357412eb73f830057cae Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Tue, 26 Dec 2017 10:24:23 +1100 Subject: Stabilized `#[repr(align(x))]` attribute (RFC 1358) --- src/libsyntax/feature_gate.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/libsyntax') 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 \ -- cgit 1.4.1-3-g733a5