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 {
53
53
54
54
/// Prepend `self.attrs` to `attrs`.
55
55
// 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 ) ;
60
59
}
61
60
62
61
pub fn is_empty ( & self ) -> bool {
Original file line number Diff line number Diff line change @@ -877,7 +877,7 @@ impl<'a> Parser<'a> {
877
877
mut e : P < Expr > ,
878
878
lo : Span ,
879
879
) -> PResult < ' a , P < Expr > > {
880
- let res = ensure_sufficient_stack ( || {
880
+ let mut res = ensure_sufficient_stack ( || {
881
881
loop {
882
882
let has_question =
883
883
if self . prev_token . kind == TokenKind :: Ident ( kw:: Return , IdentIsRaw :: No ) {
@@ -924,17 +924,13 @@ impl<'a> Parser<'a> {
924
924
925
925
// Stitch the list of outer attributes onto the return value. A little
926
926
// 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)
937
932
}
933
+ res
938
934
}
939
935
940
936
pub ( super ) fn parse_dot_suffix_expr (
You can’t perform that action at this time.
0 commit comments