@@ -38,36 +38,6 @@ use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span};
3838use thin_vec:: { thin_vec, ThinVec } ;
3939use tracing:: instrument;
4040
41- /// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
42- /// dropped into the token stream, which happens while parsing the result of
43- /// macro expansion). Placement of these is not as complex as I feared it would
44- /// be. The important thing is to make sure that lookahead doesn't balk at
45- /// `token::Interpolated` tokens.
46- macro_rules! maybe_whole_expr {
47- ( $p: expr) => {
48- if let token:: Interpolated ( nt) = & $p. token. kind {
49- match & * * nt {
50- token:: NtExpr ( e) | token:: NtLiteral ( e) => {
51- let e = e. clone( ) ;
52- $p. bump( ) ;
53- return Ok ( e) ;
54- }
55- token:: NtPath ( path) => {
56- let path = ( * * path) . clone( ) ;
57- $p. bump( ) ;
58- return Ok ( $p. mk_expr( $p. prev_token. span, ExprKind :: Path ( None , path) ) ) ;
59- }
60- token:: NtBlock ( block) => {
61- let block = block. clone( ) ;
62- $p. bump( ) ;
63- return Ok ( $p. mk_expr( $p. prev_token. span, ExprKind :: Block ( block, None ) ) ) ;
64- }
65- _ => { }
66- } ;
67- }
68- } ;
69- }
70-
7141#[ derive( Debug ) ]
7242pub ( super ) enum LhsExpr {
7343 NotYetParsed ,
@@ -1438,7 +1408,27 @@ impl<'a> Parser<'a> {
14381408 /// correctly if called from `parse_dot_or_call_expr()`.
14391409 fn parse_expr_bottom ( & mut self ) -> PResult < ' a , P < Expr > > {
14401410 maybe_recover_from_interpolated_ty_qpath ! ( self , true ) ;
1441- maybe_whole_expr ! ( self ) ;
1411+
1412+ if let token:: Interpolated ( nt) = & self . token . kind {
1413+ match & * * nt {
1414+ token:: NtExpr ( e) | token:: NtLiteral ( e) => {
1415+ let e = e. clone ( ) ;
1416+ self . bump ( ) ;
1417+ return Ok ( e) ;
1418+ }
1419+ token:: NtPath ( path) => {
1420+ let path = ( * * path) . clone ( ) ;
1421+ self . bump ( ) ;
1422+ return Ok ( self . mk_expr ( self . prev_token . span , ExprKind :: Path ( None , path) ) ) ;
1423+ }
1424+ token:: NtBlock ( block) => {
1425+ let block = block. clone ( ) ;
1426+ self . bump ( ) ;
1427+ return Ok ( self . mk_expr ( self . prev_token . span , ExprKind :: Block ( block, None ) ) ) ;
1428+ }
1429+ _ => { }
1430+ } ;
1431+ }
14421432
14431433 // Outer attributes are already parsed and will be
14441434 // added to the return value after the fact.
@@ -2207,7 +2197,16 @@ impl<'a> Parser<'a> {
22072197 /// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`).
22082198 /// Keep this in sync with `Token::can_begin_literal_maybe_minus`.
22092199 pub fn parse_literal_maybe_minus ( & mut self ) -> PResult < ' a , P < Expr > > {
2210- maybe_whole_expr ! ( self ) ;
2200+ if let token:: Interpolated ( nt) = & self . token . kind {
2201+ match & * * nt {
2202+ token:: NtExpr ( e) | token:: NtLiteral ( e) => {
2203+ let e = e. clone ( ) ;
2204+ self . bump ( ) ;
2205+ return Ok ( e) ;
2206+ }
2207+ _ => { }
2208+ } ;
2209+ }
22112210
22122211 let lo = self . token . span ;
22132212 let minus_present = self . eat ( & token:: BinOp ( token:: Minus ) ) ;
0 commit comments