Skip to content

Commit

Permalink
Rollup merge of rust-lang#65686 - yjhmelody:yjhmelody-patch-1, r=Centril
Browse files Browse the repository at this point in the history
refactor and move `maybe_append`
  • Loading branch information
JohnTitor authored Oct 23, 2019
2 parents 7fc6ce9 + 40f92b3 commit 5bac361
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 0 additions & 7 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions src/libsyntax/parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5bac361

Please sign in to comment.