Rollup merge of #65686 - yjhmelody:yjhmelody-patch-1, r=Centril

refactor and move `maybe_append`
This commit is contained in:
Yuki Okushi 2019-10-23 17:14:42 +09:00 committed by GitHub
commit 5bac361776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -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,

View File

@ -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,