File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -535,6 +535,7 @@ impl<'a> FilterAttrs<'a> for &'a [Attribute] {
535535#[ cfg( feature = "parsing" ) ]
536536pub ( crate ) mod parsing {
537537 use super :: * ;
538+ use crate :: parse:: discouraged:: Speculative ;
538539 use crate :: parse:: { Parse , ParseStream , Result } ;
539540
540541 pub ( crate ) fn parse_inner ( input : ParseStream , attrs : & mut Vec < Attribute > ) -> Result < ( ) > {
@@ -609,10 +610,19 @@ pub(crate) mod parsing {
609610
610611 fn parse_meta_name_value_after_path ( path : Path , input : ParseStream ) -> Result < MetaNameValue > {
611612 let eq_token: Token ! [ =] = input. parse ( ) ?;
612- if input. peek ( Token ! [ #] ) && input. peek2 ( token:: Bracket ) {
613+ let ahead = input. fork ( ) ;
614+ let lit: Option < Lit > = ahead. parse ( ) ?;
615+ let value = if let ( Some ( lit) , true ) = ( lit, ahead. is_empty ( ) ) {
616+ input. advance_to ( & ahead) ;
617+ Expr :: Lit ( ExprLit {
618+ attrs : Vec :: new ( ) ,
619+ lit,
620+ } )
621+ } else if input. peek ( Token ! [ #] ) && input. peek2 ( token:: Bracket ) {
613622 return Err ( input. error ( "unexpected attribute inside of attribute" ) ) ;
614- }
615- let value: Expr = input. parse ( ) ?;
623+ } else {
624+ input. parse ( ) ?
625+ } ;
616626 Ok ( MetaNameValue {
617627 path,
618628 eq_token,
You can’t perform that action at this time.
0 commit comments