Skip to content

Commit 5bac361

Browse files
authored
Rollup merge of #65686 - yjhmelody:yjhmelody-patch-1, r=Centril
refactor and move `maybe_append`
2 parents 7fc6ce9 + 40f92b3 commit 5bac361

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/libsyntax/parse/parser.rs

-7
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath {
8686
}
8787
}
8888

89-
fn maybe_append(mut lhs: Vec<Attribute>, mut rhs: Option<Vec<Attribute>>) -> Vec<Attribute> {
90-
if let Some(ref mut rhs) = rhs {
91-
lhs.append(rhs);
92-
}
93-
lhs
94-
}
95-
9689
#[derive(Debug, Clone, Copy, PartialEq)]
9790
enum PrevTokenKind {
9891
DocComment,

src/libsyntax/parse/parser/item.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem,
1010
use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField};
1111
use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param};
1212
use crate::parse::token;
13-
use crate::parse::parser::maybe_append;
1413
use crate::tokenstream::{TokenTree, TokenStream};
1514
use crate::symbol::{kw, sym};
1615
use crate::source_map::{self, respan, Span};
@@ -416,10 +415,17 @@ impl<'a> Parser<'a> {
416415
) -> PResult<'a, Option<P<Item>>> {
417416
let (ident, item, extra_attrs) = info;
418417
let span = lo.to(self.prev_span);
419-
let attrs = maybe_append(attrs, extra_attrs);
418+
let attrs = Self::maybe_append(attrs, extra_attrs);
420419
Ok(Some(self.mk_item(span, ident, item, vis, attrs)))
421420
}
422421

422+
fn maybe_append<T>(mut lhs: Vec<T>, mut rhs: Option<Vec<T>>) -> Vec<T> {
423+
if let Some(ref mut rhs) = rhs {
424+
lhs.append(rhs);
425+
}
426+
lhs
427+
}
428+
423429
/// This is the fall-through for parsing items.
424430
fn parse_macro_use_or_failure(
425431
&mut self,

0 commit comments

Comments
 (0)