File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -53,10 +53,9 @@ impl AttrWrapper {
5353
5454 /// Prepend `self.attrs` to `attrs`.
5555 // FIXME: require passing an NT to prevent misuse of this method
56- pub ( crate ) fn prepend_to_nt_inner ( self , attrs : & mut AttrVec ) {
57- let mut self_attrs = self . attrs ;
58- mem:: swap ( attrs, & mut self_attrs) ;
59- attrs. extend ( self_attrs) ;
56+ pub ( crate ) fn prepend_to_nt_inner ( mut self , attrs : & mut AttrVec ) {
57+ mem:: swap ( attrs, & mut self . attrs ) ;
58+ attrs. extend ( self . attrs ) ;
6059 }
6160
6261 pub fn is_empty ( & self ) -> bool {
Original file line number Diff line number Diff line change @@ -877,7 +877,7 @@ impl<'a> Parser<'a> {
877877 mut e : P < Expr > ,
878878 lo : Span ,
879879 ) -> PResult < ' a , P < Expr > > {
880- let res = ensure_sufficient_stack ( || {
880+ let mut res = ensure_sufficient_stack ( || {
881881 loop {
882882 let has_question =
883883 if self . prev_token . kind == TokenKind :: Ident ( kw:: Return , IdentIsRaw :: No ) {
@@ -924,17 +924,13 @@ impl<'a> Parser<'a> {
924924
925925 // Stitch the list of outer attributes onto the return value. A little
926926 // bit ugly, but the best way given the current code structure.
927- if attrs. is_empty ( ) {
928- res
929- } else {
930- res. map ( |expr| {
931- expr. map ( |mut expr| {
932- attrs. extend ( expr. attrs ) ;
933- expr. attrs = attrs;
934- expr
935- } )
936- } )
927+ if !attrs. is_empty ( )
928+ && let Ok ( expr) = & mut res
929+ {
930+ mem:: swap ( & mut expr. attrs , & mut attrs) ;
931+ expr. attrs . extend ( attrs)
937932 }
933+ res
938934 }
939935
940936 pub ( super ) fn parse_dot_suffix_expr (
You can’t perform that action at this time.
0 commit comments