@@ -38,36 +38,6 @@ use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span};
38
38
use thin_vec:: { thin_vec, ThinVec } ;
39
39
use tracing:: instrument;
40
40
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
-
71
41
#[ derive( Debug ) ]
72
42
pub ( super ) enum LhsExpr {
73
43
NotYetParsed ,
@@ -1438,7 +1408,27 @@ impl<'a> Parser<'a> {
1438
1408
/// correctly if called from `parse_dot_or_call_expr()`.
1439
1409
fn parse_expr_bottom ( & mut self ) -> PResult < ' a , P < Expr > > {
1440
1410
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
+ }
1442
1432
1443
1433
// Outer attributes are already parsed and will be
1444
1434
// added to the return value after the fact.
@@ -2207,7 +2197,16 @@ impl<'a> Parser<'a> {
2207
2197
/// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`).
2208
2198
/// Keep this in sync with `Token::can_begin_literal_maybe_minus`.
2209
2199
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
+ }
2211
2210
2212
2211
let lo = self . token . span ;
2213
2212
let minus_present = self . eat ( & token:: BinOp ( token:: Minus ) ) ;
0 commit comments