@@ -934,16 +934,22 @@ impl<'a> Parser<'a> {
934934 is_interpolated_expr = true ;
935935 }
936936 }
937- let token_tree = if is_interpolated_expr {
937+ let token_stream : TokenStream = if is_interpolated_expr {
938938 // We need to accept arbitrary interpolated expressions to continue
939939 // supporting things like `doc = $expr` that work on stable.
940940 // Non-literal interpolated expressions are rejected after expansion.
941- self . parse_token_tree ( )
941+ self . parse_token_tree ( ) . into ( )
942+ } else if let Some ( lit) = self . parse_opt_lit ( ) {
943+ self . require_unsuffixed ( & lit) ;
944+ lit. token_tree ( ) . into ( )
945+ } else if self . check ( & token:: ModSep ) || self . token . ident ( ) . is_some ( ) {
946+ self . collect_tokens_only ( |this| this. parse_path ( PathStyle :: Mod ) ) ?
942947 } else {
943- self . parse_unsuffixed_lit ( ) ?. token_tree ( )
948+ let msg = "expected a literal or ::-separated path" ;
949+ return Err ( self . struct_span_err ( self . token . span , msg) ) ;
944950 } ;
945951
946- MacArgs :: Eq ( eq_span, token_tree . into ( ) )
952+ MacArgs :: Eq ( eq_span, token_stream )
947953 } else {
948954 MacArgs :: Empty
949955 }
@@ -1254,6 +1260,14 @@ impl<'a> Parser<'a> {
12541260 Ok ( ( ret, Some ( LazyTokenStream :: new ( lazy_impl) ) ) )
12551261 }
12561262
1263+ fn collect_tokens_only < R > (
1264+ & mut self ,
1265+ f : impl FnOnce ( & mut Self ) -> PResult < ' a , R > ,
1266+ ) -> PResult < ' a , TokenStream > {
1267+ let ( _ignored, tokens) = self . collect_tokens ( f) ?;
1268+ Ok ( tokens)
1269+ }
1270+
12571271 /// `::{` or `::*`
12581272 fn is_import_coupler ( & mut self ) -> bool {
12591273 self . check ( & token:: ModSep )
0 commit comments