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

update rustc_ap_syntax #2609

Merged
merged 1 commit into from
Apr 8, 2018
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
48 changes: 24 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ env_logger = "0.5"
getopts = "0.2"
derive-new = "0.5"
cargo_metadata = "0.5.1"
rustc-ap-syntax = "89.0.0"
rustc-ap-syntax = "91.0.0"

[dev-dependencies]
lazy_static = "1.0.0"
Expand Down
6 changes: 3 additions & 3 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ fn allow_mixed_tactic_for_nested_metaitem_list(list: &[ast::NestedMetaItem]) ->
impl Rewrite for ast::MetaItem {
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
Some(match self.node {
ast::MetaItemKind::Word => String::from(&*self.name.as_str()),
ast::MetaItemKind::Word => String::from(&*self.ident.name.as_str()),
ast::MetaItemKind::List(ref list) => {
let name = self.name.as_str();
let name = self.ident.name.as_str();
let item_shape = match context.config.indent_style() {
IndentStyle::Block => shape
.block_indent(context.config.tab_spaces())
Expand Down Expand Up @@ -259,7 +259,7 @@ impl Rewrite for ast::MetaItem {
}
}
ast::MetaItemKind::NameValue(ref literal) => {
let name = self.name.as_str();
let name = self.ident.name.as_str();
// 3 = ` = `
let lit_shape = shape.shrink_left(name.len() + 3)?;
// `rewrite_literal` returns `None` when `literal` exceeds max
Expand Down
4 changes: 2 additions & 2 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ fn rewrite_chain_subexpr(
},
_ => &[],
};
rewrite_method_call(segment.identifier, types, expressions, span, context, shape)
rewrite_method_call(segment.ident, types, expressions, span, context, shape)
}
ast::ExprKind::Field(_, ref field) => rewrite_element(format!(".{}", field.node)),
ast::ExprKind::Field(_, ref field) => rewrite_element(format!(".{}", field.name)),
ast::ExprKind::TupField(ref expr, ref field) => {
let space = match expr.node {
ast::ExprKind::TupField(..) => " ",
Expand Down
13 changes: 10 additions & 3 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ pub fn format_expr(
},
ast::ExprKind::Closure(capture, movability, ref fn_decl, ref body, _) => {
closures::rewrite_closure(
capture, movability, fn_decl, body, expr.span, context, shape,
capture,
movability,
fn_decl,
body,
expr.span,
context,
shape,
)
}
ast::ExprKind::Try(..)
Expand Down Expand Up @@ -928,7 +934,8 @@ impl<'a> ControlFlow<'a> {

// `for event in event`
// Do not include label in the span.
let lo = self.label.map_or(self.span.lo(), |label| label.span.hi());
let lo = self.label
.map_or(self.span.lo(), |label| label.ident.span.hi());
let between_kwd_cond = mk_sp(
context
.snippet_provider
Expand Down Expand Up @@ -1702,7 +1709,7 @@ pub fn rewrite_field(
if !attrs_str.is_empty() {
attrs_str.push_str(&shape.indent.to_string_with_newline(context.config));
};
let name = field.ident.node.to_string();
let name = &field.ident.name.to_string();
if field.is_shorthand {
Some(attrs_str + &name)
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::borrow::Cow;
/// Returns a name imported by a `use` declaration. e.g. returns `Ordering`
/// for `std::cmp::Ordering` and `self` for `std::cmp::self`.
pub fn path_to_imported_ident(path: &ast::Path) -> ast::Ident {
path.segments.last().unwrap().identifier
path.segments.last().unwrap().ident
}

impl<'a> FmtVisitor<'a> {
Expand Down Expand Up @@ -129,7 +129,7 @@ impl UseSegment {
}

fn from_path_segment(path_seg: &ast::PathSegment) -> Option<UseSegment> {
let name = path_seg.identifier.name.as_str();
let name = path_seg.ident.name.as_str();
if name == "{{root}}" {
return None;
}
Expand Down
10 changes: 5 additions & 5 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ impl<'a> FmtVisitor<'a> {
)?,
ast::VariantData::Unit(..) => {
if let Some(ref expr) = field.node.disr_expr {
let lhs = format!("{} =", field.node.name);
let lhs = format!("{} =", field.node.ident.name);
rewrite_assign_rhs(&context, lhs, &**expr, shape)?
} else {
field.node.name.to_string()
field.node.ident.name.to_string()
}
}
};
Expand Down Expand Up @@ -893,7 +893,7 @@ impl<'a> StructParts<'a> {
fn from_variant(variant: &'a ast::Variant) -> Self {
StructParts {
prefix: "",
ident: variant.node.name,
ident: variant.node.ident,
vis: &DEFAULT_VISIBILITY,
def: &variant.node.data,
generics: None,
Expand Down Expand Up @@ -1794,7 +1794,7 @@ pub fn span_hi_for_arg(context: &RewriteContext, arg: &ast::Arg) -> BytePos {

pub fn is_named_arg(arg: &ast::Arg) -> bool {
if let ast::PatKind::Ident(_, ident, _) = arg.pat.node {
ident.node != symbol::keywords::Invalid.ident()
ident != symbol::keywords::Invalid.ident()
} else {
true
}
Expand Down Expand Up @@ -2263,7 +2263,7 @@ fn rewrite_args(

fn arg_has_pattern(arg: &ast::Arg) -> bool {
if let ast::PatKind::Ident(_, ident, _) = arg.pat.node {
ident.node != symbol::keywords::Invalid.ident()
ident != symbol::keywords::Invalid.ident()
} else {
true
}
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn parse_macro_arg(parser: &mut Parser) -> Option<MacroArg> {
fn rewrite_macro_name(path: &ast::Path, extra_ident: Option<ast::Ident>) -> String {
let name = if path.segments.len() == 1 {
// Avoid using pretty-printer in the common case.
format!("{}!", path.segments[0].identifier)
format!("{}!", path.segments[0].ident)
} else {
format!("{}!", path)
};
Expand Down
2 changes: 1 addition & 1 deletion src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Rewrite for Pat {
BindingMode::ByValue(mutability) => ("", mutability),
};
let mut_infix = format_mutability(mutability);
let id_str = ident.node.to_string();
let id_str = ident.name.to_string();
let sub_pat = match *sub_pat {
Some(ref p) => {
// 3 - ` @ `.
Expand Down
12 changes: 6 additions & 6 deletions src/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ impl Spanned for ast::TyParam {
fn span(&self) -> Span {
// Note that ty.span is the span for ty.ident, not the whole item.
let lo = if self.attrs.is_empty() {
self.span.lo()
self.ident.span.lo()
} else {
self.attrs[0].span.lo()
};
if let Some(ref def) = self.default {
return mk_sp(lo, def.span.hi());
}
if self.bounds.is_empty() {
return mk_sp(lo, self.span.hi());
return mk_sp(lo, self.ident.span.hi());
}
let hi = self.bounds[self.bounds.len() - 1].span().hi();
mk_sp(lo, hi)
Expand All @@ -165,19 +165,19 @@ impl Spanned for ast::TyParamBound {
fn span(&self) -> Span {
match *self {
ast::TyParamBound::TraitTyParamBound(ref ptr, _) => ptr.span,
ast::TyParamBound::RegionTyParamBound(ref l) => l.span,
ast::TyParamBound::RegionTyParamBound(ref l) => l.ident.span,
}
}
}

impl Spanned for ast::LifetimeDef {
fn span(&self) -> Span {
let hi = if self.bounds.is_empty() {
self.lifetime.span.hi()
self.lifetime.ident.span.hi()
} else {
self.bounds[self.bounds.len() - 1].span.hi()
self.bounds[self.bounds.len() - 1].ident.span.hi()
};
mk_sp(self.lifetime.span.lo(), hi)
mk_sp(self.lifetime.ident.span.lo(), hi)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ where

for segment in iter {
// Indicates a global path, shouldn't be rendered.
if segment.identifier.name == keywords::CrateRoot.name() {
if segment.ident.name == keywords::CrateRoot.name() {
continue;
}
if first {
Expand Down Expand Up @@ -155,7 +155,7 @@ enum SegmentParam<'a> {
impl<'a> Spanned for SegmentParam<'a> {
fn span(&self) -> Span {
match *self {
SegmentParam::LifeTime(lt) => lt.span,
SegmentParam::LifeTime(lt) => lt.ident.span,
SegmentParam::Type(ty) => ty.span,
SegmentParam::Binding(binding) => binding.span,
}
Expand Down Expand Up @@ -215,7 +215,7 @@ fn rewrite_segment(
shape: Shape,
) -> Option<String> {
let mut result = String::with_capacity(128);
result.push_str(&segment.identifier.name.as_str());
result.push_str(&segment.ident.name.as_str());

let ident_len = result.len();
let shape = if context.use_block_indent() {
Expand Down
6 changes: 3 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn format_visibility(vis: &Visibility) -> Cow<'static, str> {
VisibilityKind::Crate(CrateSugar::JustCrate) => Cow::from("crate "),
VisibilityKind::Restricted { ref path, .. } => {
let Path { ref segments, .. } = **path;
let mut segments_iter = segments.iter().map(|seg| seg.identifier.name.to_string());
let mut segments_iter = segments.iter().map(|seg| seg.ident.name.to_string());
if path.is_global() {
segments_iter
.next()
Expand Down Expand Up @@ -190,9 +190,9 @@ pub fn last_line_extendable(s: &str) -> bool {
#[inline]
fn is_skip(meta_item: &MetaItem) -> bool {
match meta_item.node {
MetaItemKind::Word => meta_item.name == SKIP_ANNOTATION,
MetaItemKind::Word => meta_item.ident.name == SKIP_ANNOTATION,
MetaItemKind::List(ref l) => {
meta_item.name == "cfg_attr" && l.len() == 2 && is_skip_nested(&l[1])
meta_item.ident.name == "cfg_attr" && l.len() == 2 && is_skip_nested(&l[1])
}
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion src/vertical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl AlignedItem for ast::Field {

fn rewrite_prefix(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
let attrs_str = self.attrs.rewrite(context, shape)?;
let name = &self.ident.node.to_string();
let name = &self.ident.name.to_string();
let missing_span = if self.attrs.is_empty() {
mk_sp(self.span.lo(), self.span.lo())
} else {
Expand Down