mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Rollup merge of #65686 - yjhmelody:yjhmelody-patch-1, r=Centril
refactor and move `maybe_append`
This commit is contained in:
commit
5bac361776
@ -86,13 +86,6 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath {
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe_append(mut lhs: Vec<Attribute>, mut rhs: Option<Vec<Attribute>>) -> Vec<Attribute> {
|
||||
if let Some(ref mut rhs) = rhs {
|
||||
lhs.append(rhs);
|
||||
}
|
||||
lhs
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
enum PrevTokenKind {
|
||||
DocComment,
|
||||
|
@ -10,7 +10,6 @@ use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem,
|
||||
use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField};
|
||||
use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param};
|
||||
use crate::parse::token;
|
||||
use crate::parse::parser::maybe_append;
|
||||
use crate::tokenstream::{TokenTree, TokenStream};
|
||||
use crate::symbol::{kw, sym};
|
||||
use crate::source_map::{self, respan, Span};
|
||||
@ -416,10 +415,17 @@ impl<'a> Parser<'a> {
|
||||
) -> PResult<'a, Option<P<Item>>> {
|
||||
let (ident, item, extra_attrs) = info;
|
||||
let span = lo.to(self.prev_span);
|
||||
let attrs = maybe_append(attrs, extra_attrs);
|
||||
let attrs = Self::maybe_append(attrs, extra_attrs);
|
||||
Ok(Some(self.mk_item(span, ident, item, vis, attrs)))
|
||||
}
|
||||
|
||||
fn maybe_append<T>(mut lhs: Vec<T>, mut rhs: Option<Vec<T>>) -> Vec<T> {
|
||||
if let Some(ref mut rhs) = rhs {
|
||||
lhs.append(rhs);
|
||||
}
|
||||
lhs
|
||||
}
|
||||
|
||||
/// This is the fall-through for parsing items.
|
||||
fn parse_macro_use_or_failure(
|
||||
&mut self,
|
||||
|
Loading…
Reference in New Issue
Block a user