@@ -289,9 +289,6 @@ declare_features! (
289289 // Allows exhaustive pattern matching on types that contain uninhabited types
290290 ( active, exhaustive_patterns, "1.13.0" , Some ( 51085 ) , None ) ,
291291
292- // Allows all literals in attribute lists and values of key-value pairs
293- ( active, attr_literals, "1.13.0" , Some ( 34981 ) , None ) ,
294-
295292 // Allows untagged unions `union U { ... }`
296293 ( active, untagged_unions, "1.13.0" , Some ( 32836 ) , None ) ,
297294
@@ -654,6 +651,8 @@ declare_features! (
654651 ( accepted, tool_attributes, "1.30.0" , Some ( 44690 ) , None ) ,
655652 // Allows multi-segment paths in attributes and derives
656653 ( accepted, proc_macro_path_invoc, "1.30.0" , Some ( 38356 ) , None ) ,
654+ // Allows all literals in attribute lists and values of key-value pairs.
655+ ( accepted, attr_literals, "1.30.0" , Some ( 34981 ) , None ) ,
657656) ;
658657
659658// If you change this, please modify src/doc/unstable-book as well. You must
@@ -1451,22 +1450,6 @@ impl<'a> PostExpansionVisitor<'a> {
14511450 }
14521451}
14531452
1454- fn contains_novel_literal ( item : & ast:: MetaItem ) -> bool {
1455- use ast:: MetaItemKind :: * ;
1456- use ast:: NestedMetaItemKind :: * ;
1457-
1458- match item. node {
1459- Word => false ,
1460- NameValue ( ref lit) => !lit. node . is_str ( ) ,
1461- List ( ref list) => list. iter ( ) . any ( |li| {
1462- match li. node {
1463- MetaItem ( ref mi) => contains_novel_literal ( mi) ,
1464- Literal ( _) => true ,
1465- }
1466- } ) ,
1467- }
1468- }
1469-
14701453impl < ' a > PostExpansionVisitor < ' a > {
14711454 fn whole_crate_feature_gates ( & mut self , _krate : & ast:: Crate ) {
14721455 for & ( ident, span) in & * self . context . parse_sess . non_modrs_mods . borrow ( ) {
@@ -1526,28 +1509,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
15261509 }
15271510
15281511 if !self . context . features . unrestricted_attribute_tokens {
1529- // Unfortunately, `parse_meta` cannot be called speculatively because it can report
1530- // errors by itself, so we have to call it only if the feature is disabled.
1531- match attr. parse_meta ( self . context . parse_sess ) {
1532- Ok ( meta) => {
1533- // allow attr_literals in #[repr(align(x))] and #[repr(packed(n))]
1534- let mut allow_attr_literal = false ;
1535- if attr. path == "repr" {
1536- if let Some ( content) = meta. meta_item_list ( ) {
1537- allow_attr_literal = content. iter ( ) . any (
1538- |c| c. check_name ( "align" ) || c. check_name ( "packed" ) ) ;
1539- }
1540- }
1541-
1542- if !allow_attr_literal && contains_novel_literal ( & meta) {
1543- gate_feature_post ! ( & self , attr_literals, attr. span,
1544- "non-string literals in attributes, or string \
1545- literals in top-level positions, are experimental") ;
1546- }
1547- }
1548- Err ( mut err) => {
1549- err. help ( "try enabling `#![feature(unrestricted_attribute_tokens)]`" ) . emit ( )
1550- }
1512+ // Unfortunately, `parse_meta` cannot be called speculatively
1513+ // because it can report errors by itself, so we have to call it
1514+ // only if the feature is disabled.
1515+ if let Err ( mut err) = attr. parse_meta ( self . context . parse_sess ) {
1516+ err. help ( "try enabling `#![feature(unrestricted_attribute_tokens)]`" ) . emit ( )
15511517 }
15521518 }
15531519 }
0 commit comments