diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/attr.rs | 6 | ||||
| -rw-r--r-- | src/chains.rs | 4 | ||||
| -rw-r--r-- | src/expr.rs | 13 | ||||
| -rw-r--r-- | src/imports.rs | 4 | ||||
| -rw-r--r-- | src/items.rs | 10 | ||||
| -rw-r--r-- | src/macros.rs | 2 | ||||
| -rw-r--r-- | src/patterns.rs | 2 | ||||
| -rw-r--r-- | src/spanned.rs | 12 | ||||
| -rw-r--r-- | src/types.rs | 6 | ||||
| -rw-r--r-- | src/utils.rs | 6 | ||||
| -rw-r--r-- | src/vertical.rs | 2 |
11 files changed, 37 insertions, 30 deletions
diff --git a/src/attr.rs b/src/attr.rs index 68d6a288896..e17b89e5c9e 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -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()) @@ -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 diff --git a/src/chains.rs b/src/chains.rs index 6c3b6d1033d..15ecd6034f3 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -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(..) => " ", diff --git a/src/expr.rs b/src/expr.rs index d2ae5ba94e1..b738d4ccb16 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -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(..) @@ -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 @@ -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 { diff --git a/src/imports.rs b/src/imports.rs index b9625a66e1e..a66bcbd3e94 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -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> { @@ -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; } diff --git a/src/items.rs b/src/items.rs index eabd234b0ee..6d474a3ccd6 100644 --- a/src/items.rs +++ b/src/items.rs @@ -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() } } }; @@ -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, @@ -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 } @@ -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 } diff --git a/src/macros.rs b/src/macros.rs index 3769c97845b..9cf033e9693 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -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) }; diff --git a/src/patterns.rs b/src/patterns.rs index bbfe55ec6e9..243b85e4267 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -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 - ` @ `. diff --git a/src/spanned.rs b/src/spanned.rs index 41fa0da8dd1..237624ab8fe 100644 --- a/src/spanned.rs +++ b/src/spanned.rs @@ -146,7 +146,7 @@ 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() }; @@ -154,7 +154,7 @@ impl Spanned for ast::TyParam { 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) @@ -165,7 +165,7 @@ 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, } } } @@ -173,11 +173,11 @@ impl Spanned for ast::TyParamBound { 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) } } diff --git a/src/types.rs b/src/types.rs index 615dc53fc4e..0c0cad8244b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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 { @@ -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, } @@ -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() { diff --git a/src/utils.rs b/src/utils.rs index 055f75b4609..dae57882a35 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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() @@ -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, } diff --git a/src/vertical.rs b/src/vertical.rs index 887fefb2272..6cdaaafeb36 100644 --- a/src/vertical.rs +++ b/src/vertical.rs @@ -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 { |
