diff options
| author | Caleb Cartwright <caleb.cartwright@outlook.com> | 2021-03-27 12:19:05 -0500 |
|---|---|---|
| committer | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2021-04-02 23:21:06 -0500 |
| commit | 49489116081f2a90ef2f51f04cf0048fbc1504a7 (patch) | |
| tree | 7978b3aeae9907117ea59a4fb52f5906fc0c557c | |
| parent | ef57c5bf6751e5a4f548c722d6aeb28f6d86664d (diff) | |
| download | rust-49489116081f2a90ef2f51f04cf0048fbc1504a7.tar.gz rust-49489116081f2a90ef2f51f04cf0048fbc1504a7.zip | |
deps: apply rustc-ap-* v712 changes
| -rw-r--r-- | src/expr.rs | 29 | ||||
| -rw-r--r-- | src/items.rs | 12 | ||||
| -rw-r--r-- | src/overflow.rs | 8 | ||||
| -rw-r--r-- | src/patterns.rs | 6 | ||||
| -rw-r--r-- | src/spanned.rs | 4 | ||||
| -rw-r--r-- | src/vertical.rs | 4 |
6 files changed, 33 insertions, 30 deletions
diff --git a/src/expr.rs b/src/expr.rs index 4589b57dacb..1befea9c805 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -106,15 +106,18 @@ pub(crate) fn format_expr( }) } ast::ExprKind::Unary(op, ref subexpr) => rewrite_unary_op(context, op, subexpr, shape), - ast::ExprKind::Struct(ref path, ref fields, ref struct_rest) => rewrite_struct_lit( - context, - path, - fields, - struct_rest, - &expr.attrs, - expr.span, - shape, - ), + ast::ExprKind::Struct(ref struct_expr) => { + let ast::StructExpr { ref fields, ref path, ref rest } = **struct_expr; + rewrite_struct_lit( + context, + path, + fields, + rest, + &expr.attrs, + expr.span, + shape, + ) + } ast::ExprKind::Tup(ref items) => { rewrite_tuple(context, items.iter(), expr.span, shape, items.len() == 1) } @@ -1496,14 +1499,14 @@ fn rewrite_index( } } -fn struct_lit_can_be_aligned(fields: &[ast::Field], has_base: bool) -> bool { +fn struct_lit_can_be_aligned(fields: &[ast::ExprField], has_base: bool) -> bool { !has_base && fields.iter().all(|field| !field.is_shorthand) } fn rewrite_struct_lit<'a>( context: &RewriteContext<'_>, path: &ast::Path, - fields: &'a [ast::Field], + fields: &'a [ast::ExprField], struct_rest: &ast::StructRest, attrs: &[ast::Attribute], span: Span, @@ -1512,7 +1515,7 @@ fn rewrite_struct_lit<'a>( debug!("rewrite_struct_lit: shape {:?}", shape); enum StructLitField<'a> { - Regular(&'a ast::Field), + Regular(&'a ast::ExprField), Base(&'a ast::Expr), Rest(&'a Span), } @@ -1668,7 +1671,7 @@ pub(crate) fn struct_lit_field_separator(config: &Config) -> &str { pub(crate) fn rewrite_field( context: &RewriteContext<'_>, - field: &ast::Field, + field: &ast::ExprField, shape: Shape, prefix_max_width: usize, ) -> Option<String> { diff --git a/src/items.rs b/src/items.rs index 00757210ce5..61b49911e76 100644 --- a/src/items.rs +++ b/src/items.rs @@ -158,7 +158,7 @@ impl<'a> Item<'a> { #[derive(Debug)] enum BodyElement<'a> { // Stmt(&'a ast::Stmt), - // Field(&'a ast::Field), + // Field(&'a ast::ExprField), // Variant(&'a ast::Variant), // Item(&'a ast::Item), ForeignItem(&'a ast::ForeignItem), @@ -1274,7 +1274,7 @@ fn format_unit_struct( pub(crate) fn format_struct_struct( context: &RewriteContext<'_>, struct_parts: &StructParts<'_>, - fields: &[ast::StructField], + fields: &[ast::FieldDef], offset: Indent, one_line_width: Option<usize>, ) -> Option<String> { @@ -1411,7 +1411,7 @@ fn format_empty_struct_or_tuple( fn format_tuple_struct( context: &RewriteContext<'_>, struct_parts: &StructParts<'_>, - fields: &[ast::StructField], + fields: &[ast::FieldDef], offset: Indent, ) -> Option<String> { let mut result = String::with_capacity(1024); @@ -1631,7 +1631,7 @@ fn type_annotation_spacing(config: &Config) -> (&str, &str) { pub(crate) fn rewrite_struct_field_prefix( context: &RewriteContext<'_>, - field: &ast::StructField, + field: &ast::FieldDef, ) -> Option<String> { let vis = format_visibility(context, &field.vis); let type_annotation_spacing = type_annotation_spacing(context.config); @@ -1646,7 +1646,7 @@ pub(crate) fn rewrite_struct_field_prefix( }) } -impl Rewrite for ast::StructField { +impl Rewrite for ast::FieldDef { fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> { rewrite_struct_field(context, self, shape, 0) } @@ -1654,7 +1654,7 @@ impl Rewrite for ast::StructField { pub(crate) fn rewrite_struct_field( context: &RewriteContext<'_>, - field: &ast::StructField, + field: &ast::FieldDef, shape: Shape, lhs_max_width: usize, ) -> Option<String> { diff --git a/src/overflow.rs b/src/overflow.rs index 566f0e36639..f1b870101e5 100644 --- a/src/overflow.rs +++ b/src/overflow.rs @@ -74,7 +74,7 @@ pub(crate) enum OverflowableItem<'a> { MacroArg(&'a MacroArg), NestedMetaItem(&'a ast::NestedMetaItem), SegmentParam(&'a SegmentParam<'a>), - StructField(&'a ast::StructField), + FieldDef(&'a ast::FieldDef), TuplePatField(&'a TuplePatField<'a>), Ty(&'a ast::Ty), } @@ -96,7 +96,7 @@ impl<'a> OverflowableItem<'a> { match self { OverflowableItem::Expr(ast::Expr { attrs, .. }) | OverflowableItem::GenericParam(ast::GenericParam { attrs, .. }) => !attrs.is_empty(), - OverflowableItem::StructField(ast::StructField { attrs, .. }) => !attrs.is_empty(), + OverflowableItem::FieldDef(ast::FieldDef { attrs, .. }) => !attrs.is_empty(), OverflowableItem::MacroArg(MacroArg::Expr(expr)) => !expr.attrs.is_empty(), OverflowableItem::MacroArg(MacroArg::Item(item)) => !item.attrs.is_empty(), _ => false, @@ -113,7 +113,7 @@ impl<'a> OverflowableItem<'a> { OverflowableItem::MacroArg(macro_arg) => f(*macro_arg), OverflowableItem::NestedMetaItem(nmi) => f(*nmi), OverflowableItem::SegmentParam(sp) => f(*sp), - OverflowableItem::StructField(sf) => f(*sf), + OverflowableItem::FieldDef(sf) => f(*sf), OverflowableItem::TuplePatField(pat) => f(*pat), OverflowableItem::Ty(ty) => f(*ty), } @@ -238,7 +238,7 @@ macro_rules! impl_into_overflowable_item_for_rustfmt_types { } } -impl_into_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, StructField, Ty); +impl_into_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, FieldDef, Ty); impl_into_overflowable_item_for_rustfmt_types!([MacroArg], [SegmentParam, TuplePatField]); pub(crate) fn into_overflowable_list<'a, T>( diff --git a/src/patterns.rs b/src/patterns.rs index f9a9388e4ab..5d43d169d60 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -1,4 +1,4 @@ -use rustc_ast::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax}; +use rustc_ast::ast::{self, BindingMode, PatField, Pat, PatKind, RangeEnd, RangeSyntax}; use rustc_ast::ptr; use rustc_span::{BytePos, Span}; @@ -259,7 +259,7 @@ impl Rewrite for Pat { fn rewrite_struct_pat( path: &ast::Path, - fields: &[ast::FieldPat], + fields: &[ast::PatField], ellipsis: bool, span: Span, context: &RewriteContext<'_>, @@ -334,7 +334,7 @@ fn rewrite_struct_pat( Some(format!("{} {{{}}}", path_str, fields_str)) } -impl Rewrite for FieldPat { +impl Rewrite for PatField { fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> { let hi_pos = if let Some(last) = self.attrs.last() { last.span.hi() diff --git a/src/spanned.rs b/src/spanned.rs index 1f6d0023e68..7e3786b7cd9 100644 --- a/src/spanned.rs +++ b/src/spanned.rs @@ -53,7 +53,7 @@ macro_rules! implement_spanned { // Implement `Spanned` for structs with `attrs` field. implement_spanned!(ast::AssocItem); implement_spanned!(ast::Expr); -implement_spanned!(ast::Field); +implement_spanned!(ast::ExprField); implement_spanned!(ast::ForeignItem); implement_spanned!(ast::Item); implement_spanned!(ast::Local); @@ -143,7 +143,7 @@ impl Spanned for ast::GenericParam { } } -impl Spanned for ast::StructField { +impl Spanned for ast::FieldDef { fn span(&self) -> Span { span_with_attrs_lo_hi!(self, self.span.lo(), self.ty.span.hi()) } diff --git a/src/vertical.rs b/src/vertical.rs index 95d1d5c2d7e..c4208848c6c 100644 --- a/src/vertical.rs +++ b/src/vertical.rs @@ -33,7 +33,7 @@ pub(crate) trait AlignedItem { ) -> Option<String>; } -impl AlignedItem for ast::StructField { +impl AlignedItem for ast::FieldDef { fn skip(&self) -> bool { contains_skip(&self.attrs) } @@ -72,7 +72,7 @@ impl AlignedItem for ast::StructField { } } -impl AlignedItem for ast::Field { +impl AlignedItem for ast::ExprField { fn skip(&self) -> bool { contains_skip(&self.attrs) } |
