@@ -845,20 +845,20 @@ impl<'a> Parser<'a> {
845
845
// could be removed without changing functionality, but it's faster
846
846
// to have it here, especially for programs with large constants.
847
847
token:: Literal ( _) => parse_lit ! ( ) ,
848
- token:: OpenDelim ( token:: Paren ) => return self . parse_tuple_parens_expr ( ) ,
848
+ token:: OpenDelim ( token:: Paren ) => return self . parse_tuple_parens_expr ( attrs ) ,
849
849
token:: OpenDelim ( token:: Brace ) => {
850
850
return self . parse_block_expr ( None , lo, BlockCheckMode :: Default , attrs) ;
851
851
}
852
852
token:: BinOp ( token:: Or ) | token:: OrOr => return self . parse_closure_expr ( attrs) ,
853
- token:: OpenDelim ( token:: Bracket ) => return self . parse_array_or_repeat_expr ( ) ,
853
+ token:: OpenDelim ( token:: Bracket ) => return self . parse_array_or_repeat_expr ( attrs ) ,
854
854
_ => {
855
855
if self . eat_lt ( ) {
856
856
let ( qself, path) = self . parse_qpath ( PathStyle :: Expr ) ?;
857
857
let hi = path. span ;
858
858
return Ok ( self . mk_expr ( lo. to ( hi) , ExprKind :: Path ( Some ( qself) , path) , attrs) ) ;
859
859
}
860
860
if self . token . is_path_start ( ) {
861
- return self . parse_path_start_expr ( ) ;
861
+ return self . parse_path_start_expr ( attrs ) ;
862
862
}
863
863
if self . check_keyword ( kw:: Move ) || self . check_keyword ( kw:: Static ) {
864
864
return self . parse_closure_expr ( attrs) ;
@@ -979,14 +979,13 @@ impl<'a> Parser<'a> {
979
979
self . maybe_recover_from_bad_qpath ( expr, true )
980
980
}
981
981
982
- fn parse_tuple_parens_expr ( & mut self ) -> PResult < ' a , P < Expr > > {
982
+ fn parse_tuple_parens_expr ( & mut self , mut attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
983
983
let lo = self . token . span ;
984
984
let mut first = true ;
985
- let mut attrs = ThinVec :: new ( ) ;
986
985
let parse_leading_attr_expr = |p : & mut Self | {
987
986
if first {
988
987
// `(#![foo] a, b, ...)` is OK...
989
- attrs = p. parse_inner_attributes ( ) ?. into ( ) ;
988
+ attrs. extend ( p. parse_inner_attributes ( ) ?) ;
990
989
// ...but not `(a, #![foo] b, ...)`.
991
990
first = false ;
992
991
}
@@ -1007,11 +1006,14 @@ impl<'a> Parser<'a> {
1007
1006
self . maybe_recover_from_bad_qpath ( expr, true )
1008
1007
}
1009
1008
1010
- fn parse_array_or_repeat_expr ( & mut self ) -> PResult < ' a , P < Expr > > {
1009
+ fn parse_array_or_repeat_expr (
1010
+ & mut self ,
1011
+ mut attrs : ThinVec < Attribute > ,
1012
+ ) -> PResult < ' a , P < Expr > > {
1011
1013
let lo = self . token . span ;
1012
1014
self . bump ( ) ; // `[`
1013
1015
1014
- let attrs = self . parse_inner_attributes ( ) ?. into ( ) ;
1016
+ attrs. extend ( self . parse_inner_attributes ( ) ?) ;
1015
1017
1016
1018
let kind = if self . eat ( & token:: CloseDelim ( token:: Bracket ) ) {
1017
1019
// Empty vector
@@ -1047,8 +1049,7 @@ impl<'a> Parser<'a> {
1047
1049
self . maybe_recover_from_bad_qpath ( expr, true )
1048
1050
}
1049
1051
1050
- fn parse_path_start_expr ( & mut self ) -> PResult < ' a , P < Expr > > {
1051
- let attrs = ThinVec :: new ( ) ;
1052
+ fn parse_path_start_expr ( & mut self , attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
1052
1053
let lo = self . token . span ;
1053
1054
let path = self . parse_path ( PathStyle :: Expr ) ?;
1054
1055
0 commit comments