Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor and move maybe_append #65686

Merged
merged 1 commit into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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