@@ -70,8 +70,8 @@ macro_rules! maybe_whole_expr {
70
70
71
71
#[ derive( Debug ) ]
72
72
pub ( super ) enum LhsExpr {
73
- // Already parsed either (a) nothing or (b) just the outer attributes.
74
- Unparsed { attrs : Option < AttrWrapper > } ,
73
+ // Already parsed just the outer attributes.
74
+ Unparsed { attrs : AttrWrapper } ,
75
75
// Already parsed the expression.
76
76
Parsed { expr : P < Expr > , starts_statement : bool } ,
77
77
}
@@ -136,6 +136,7 @@ impl<'a> Parser<'a> {
136
136
r : Restrictions ,
137
137
attrs : Option < AttrWrapper > ,
138
138
) -> PResult < ' a , P < Expr > > {
139
+ let attrs = self . parse_or_use_outer_attributes ( attrs) ?;
139
140
self . with_res ( r, |this| this. parse_expr_assoc_with ( 0 , LhsExpr :: Unparsed { attrs } ) )
140
141
}
141
142
@@ -152,7 +153,6 @@ impl<'a> Parser<'a> {
152
153
expr
153
154
}
154
155
LhsExpr :: Unparsed { attrs } => {
155
- let attrs = self . parse_or_use_outer_attributes ( attrs) ?;
156
156
if self . token . is_range_separator ( ) {
157
157
return self . parse_expr_prefix_range ( attrs) ;
158
158
} else {
@@ -295,10 +295,8 @@ impl<'a> Parser<'a> {
295
295
Fixity :: None => 1 ,
296
296
} ;
297
297
let rhs = self . with_res ( restrictions - Restrictions :: STMT_EXPR , |this| {
298
- this. parse_expr_assoc_with (
299
- prec + prec_adjustment,
300
- LhsExpr :: Unparsed { attrs : None } ,
301
- )
298
+ let attrs = this. parse_outer_attributes ( ) ?;
299
+ this. parse_expr_assoc_with ( prec + prec_adjustment, LhsExpr :: Unparsed { attrs } )
302
300
} ) ?;
303
301
304
302
let span = self . mk_expr_sp ( & lhs, lhs_span, rhs. span ) ;
@@ -471,8 +469,9 @@ impl<'a> Parser<'a> {
471
469
) -> PResult < ' a , P < Expr > > {
472
470
let rhs = if self . is_at_start_of_range_notation_rhs ( ) {
473
471
let maybe_lt = self . token . clone ( ) ;
472
+ let attrs = self . parse_outer_attributes ( ) ?;
474
473
Some (
475
- self . parse_expr_assoc_with ( prec + 1 , LhsExpr :: Unparsed { attrs : None } )
474
+ self . parse_expr_assoc_with ( prec + 1 , LhsExpr :: Unparsed { attrs } )
476
475
. map_err ( |err| self . maybe_err_dotdotlt_syntax ( maybe_lt, err) ) ?,
477
476
)
478
477
} else {
@@ -528,9 +527,10 @@ impl<'a> Parser<'a> {
528
527
this. bump ( ) ;
529
528
let ( span, opt_end) = if this. is_at_start_of_range_notation_rhs ( ) {
530
529
// RHS must be parsed with more associativity than the dots.
530
+ let attrs = this. parse_outer_attributes ( ) ?;
531
531
this. parse_expr_assoc_with (
532
532
op. unwrap ( ) . precedence ( ) + 1 ,
533
- LhsExpr :: Unparsed { attrs : None } ,
533
+ LhsExpr :: Unparsed { attrs } ,
534
534
)
535
535
. map ( |x| ( lo. to ( x. span ) , Some ( x) ) )
536
536
. map_err ( |err| this. maybe_err_dotdotlt_syntax ( maybe_lt, err) ) ?
@@ -2639,9 +2639,10 @@ impl<'a> Parser<'a> {
2639
2639
} else {
2640
2640
self . expect ( & token:: Eq ) ?;
2641
2641
}
2642
+ let attrs = self . parse_outer_attributes ( ) ?;
2642
2643
let expr = self . parse_expr_assoc_with (
2643
2644
1 + prec_let_scrutinee_needs_par ( ) ,
2644
- LhsExpr :: Unparsed { attrs : None } ,
2645
+ LhsExpr :: Unparsed { attrs } ,
2645
2646
) ?;
2646
2647
let span = lo. to ( expr. span ) ;
2647
2648
Ok ( self . mk_expr ( span, ExprKind :: Let ( pat, expr, span, recovered) ) )
0 commit comments