@@ -934,16 +934,22 @@ impl<'a> Parser<'a> {
934
934
is_interpolated_expr = true ;
935
935
}
936
936
}
937
- let token_tree = if is_interpolated_expr {
937
+ let token_stream : TokenStream = if is_interpolated_expr {
938
938
// We need to accept arbitrary interpolated expressions to continue
939
939
// supporting things like `doc = $expr` that work on stable.
940
940
// 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 ) ) ?
942
947
} 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) ) ;
944
950
} ;
945
951
946
- MacArgs :: Eq ( eq_span, token_tree . into ( ) )
952
+ MacArgs :: Eq ( eq_span, token_stream )
947
953
} else {
948
954
MacArgs :: Empty
949
955
}
@@ -1254,6 +1260,14 @@ impl<'a> Parser<'a> {
1254
1260
Ok ( ( ret, Some ( LazyTokenStream :: new ( lazy_impl) ) ) )
1255
1261
}
1256
1262
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
+
1257
1271
/// `::{` or `::*`
1258
1272
fn is_import_coupler ( & mut self ) -> bool {
1259
1273
self . check ( & token:: ModSep )
0 commit comments