Skip to content

Commit 4948911

Browse files
deps: apply rustc-ap-* v712 changes
1 parent ef57c5b commit 4948911

File tree

6 files changed

+33
-30
lines changed

6 files changed

+33
-30
lines changed

src/expr.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,18 @@ pub(crate) fn format_expr(
106106
})
107107
}
108108
ast::ExprKind::Unary(op, ref subexpr) => rewrite_unary_op(context, op, subexpr, shape),
109-
ast::ExprKind::Struct(ref path, ref fields, ref struct_rest) => rewrite_struct_lit(
110-
context,
111-
path,
112-
fields,
113-
struct_rest,
114-
&expr.attrs,
115-
expr.span,
116-
shape,
117-
),
109+
ast::ExprKind::Struct(ref struct_expr) => {
110+
let ast::StructExpr { ref fields, ref path, ref rest } = **struct_expr;
111+
rewrite_struct_lit(
112+
context,
113+
path,
114+
fields,
115+
rest,
116+
&expr.attrs,
117+
expr.span,
118+
shape,
119+
)
120+
}
118121
ast::ExprKind::Tup(ref items) => {
119122
rewrite_tuple(context, items.iter(), expr.span, shape, items.len() == 1)
120123
}
@@ -1496,14 +1499,14 @@ fn rewrite_index(
14961499
}
14971500
}
14981501

1499-
fn struct_lit_can_be_aligned(fields: &[ast::Field], has_base: bool) -> bool {
1502+
fn struct_lit_can_be_aligned(fields: &[ast::ExprField], has_base: bool) -> bool {
15001503
!has_base && fields.iter().all(|field| !field.is_shorthand)
15011504
}
15021505

15031506
fn rewrite_struct_lit<'a>(
15041507
context: &RewriteContext<'_>,
15051508
path: &ast::Path,
1506-
fields: &'a [ast::Field],
1509+
fields: &'a [ast::ExprField],
15071510
struct_rest: &ast::StructRest,
15081511
attrs: &[ast::Attribute],
15091512
span: Span,
@@ -1512,7 +1515,7 @@ fn rewrite_struct_lit<'a>(
15121515
debug!("rewrite_struct_lit: shape {:?}", shape);
15131516

15141517
enum StructLitField<'a> {
1515-
Regular(&'a ast::Field),
1518+
Regular(&'a ast::ExprField),
15161519
Base(&'a ast::Expr),
15171520
Rest(&'a Span),
15181521
}
@@ -1668,7 +1671,7 @@ pub(crate) fn struct_lit_field_separator(config: &Config) -> &str {
16681671

16691672
pub(crate) fn rewrite_field(
16701673
context: &RewriteContext<'_>,
1671-
field: &ast::Field,
1674+
field: &ast::ExprField,
16721675
shape: Shape,
16731676
prefix_max_width: usize,
16741677
) -> Option<String> {

src/items.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<'a> Item<'a> {
158158
#[derive(Debug)]
159159
enum BodyElement<'a> {
160160
// Stmt(&'a ast::Stmt),
161-
// Field(&'a ast::Field),
161+
// Field(&'a ast::ExprField),
162162
// Variant(&'a ast::Variant),
163163
// Item(&'a ast::Item),
164164
ForeignItem(&'a ast::ForeignItem),
@@ -1274,7 +1274,7 @@ fn format_unit_struct(
12741274
pub(crate) fn format_struct_struct(
12751275
context: &RewriteContext<'_>,
12761276
struct_parts: &StructParts<'_>,
1277-
fields: &[ast::StructField],
1277+
fields: &[ast::FieldDef],
12781278
offset: Indent,
12791279
one_line_width: Option<usize>,
12801280
) -> Option<String> {
@@ -1411,7 +1411,7 @@ fn format_empty_struct_or_tuple(
14111411
fn format_tuple_struct(
14121412
context: &RewriteContext<'_>,
14131413
struct_parts: &StructParts<'_>,
1414-
fields: &[ast::StructField],
1414+
fields: &[ast::FieldDef],
14151415
offset: Indent,
14161416
) -> Option<String> {
14171417
let mut result = String::with_capacity(1024);
@@ -1631,7 +1631,7 @@ fn type_annotation_spacing(config: &Config) -> (&str, &str) {
16311631

16321632
pub(crate) fn rewrite_struct_field_prefix(
16331633
context: &RewriteContext<'_>,
1634-
field: &ast::StructField,
1634+
field: &ast::FieldDef,
16351635
) -> Option<String> {
16361636
let vis = format_visibility(context, &field.vis);
16371637
let type_annotation_spacing = type_annotation_spacing(context.config);
@@ -1646,15 +1646,15 @@ pub(crate) fn rewrite_struct_field_prefix(
16461646
})
16471647
}
16481648

1649-
impl Rewrite for ast::StructField {
1649+
impl Rewrite for ast::FieldDef {
16501650
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
16511651
rewrite_struct_field(context, self, shape, 0)
16521652
}
16531653
}
16541654

16551655
pub(crate) fn rewrite_struct_field(
16561656
context: &RewriteContext<'_>,
1657-
field: &ast::StructField,
1657+
field: &ast::FieldDef,
16581658
shape: Shape,
16591659
lhs_max_width: usize,
16601660
) -> Option<String> {

src/overflow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub(crate) enum OverflowableItem<'a> {
7474
MacroArg(&'a MacroArg),
7575
NestedMetaItem(&'a ast::NestedMetaItem),
7676
SegmentParam(&'a SegmentParam<'a>),
77-
StructField(&'a ast::StructField),
77+
FieldDef(&'a ast::FieldDef),
7878
TuplePatField(&'a TuplePatField<'a>),
7979
Ty(&'a ast::Ty),
8080
}
@@ -96,7 +96,7 @@ impl<'a> OverflowableItem<'a> {
9696
match self {
9797
OverflowableItem::Expr(ast::Expr { attrs, .. })
9898
| OverflowableItem::GenericParam(ast::GenericParam { attrs, .. }) => !attrs.is_empty(),
99-
OverflowableItem::StructField(ast::StructField { attrs, .. }) => !attrs.is_empty(),
99+
OverflowableItem::FieldDef(ast::FieldDef { attrs, .. }) => !attrs.is_empty(),
100100
OverflowableItem::MacroArg(MacroArg::Expr(expr)) => !expr.attrs.is_empty(),
101101
OverflowableItem::MacroArg(MacroArg::Item(item)) => !item.attrs.is_empty(),
102102
_ => false,
@@ -113,7 +113,7 @@ impl<'a> OverflowableItem<'a> {
113113
OverflowableItem::MacroArg(macro_arg) => f(*macro_arg),
114114
OverflowableItem::NestedMetaItem(nmi) => f(*nmi),
115115
OverflowableItem::SegmentParam(sp) => f(*sp),
116-
OverflowableItem::StructField(sf) => f(*sf),
116+
OverflowableItem::FieldDef(sf) => f(*sf),
117117
OverflowableItem::TuplePatField(pat) => f(*pat),
118118
OverflowableItem::Ty(ty) => f(*ty),
119119
}
@@ -238,7 +238,7 @@ macro_rules! impl_into_overflowable_item_for_rustfmt_types {
238238
}
239239
}
240240

241-
impl_into_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, StructField, Ty);
241+
impl_into_overflowable_item_for_ast_node!(Expr, GenericParam, NestedMetaItem, FieldDef, Ty);
242242
impl_into_overflowable_item_for_rustfmt_types!([MacroArg], [SegmentParam, TuplePatField]);
243243

244244
pub(crate) fn into_overflowable_list<'a, T>(

src/patterns.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_ast::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
1+
use rustc_ast::ast::{self, BindingMode, PatField, Pat, PatKind, RangeEnd, RangeSyntax};
22
use rustc_ast::ptr;
33
use rustc_span::{BytePos, Span};
44

@@ -259,7 +259,7 @@ impl Rewrite for Pat {
259259

260260
fn rewrite_struct_pat(
261261
path: &ast::Path,
262-
fields: &[ast::FieldPat],
262+
fields: &[ast::PatField],
263263
ellipsis: bool,
264264
span: Span,
265265
context: &RewriteContext<'_>,
@@ -334,7 +334,7 @@ fn rewrite_struct_pat(
334334
Some(format!("{} {{{}}}", path_str, fields_str))
335335
}
336336

337-
impl Rewrite for FieldPat {
337+
impl Rewrite for PatField {
338338
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
339339
let hi_pos = if let Some(last) = self.attrs.last() {
340340
last.span.hi()

src/spanned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ macro_rules! implement_spanned {
5353
// Implement `Spanned` for structs with `attrs` field.
5454
implement_spanned!(ast::AssocItem);
5555
implement_spanned!(ast::Expr);
56-
implement_spanned!(ast::Field);
56+
implement_spanned!(ast::ExprField);
5757
implement_spanned!(ast::ForeignItem);
5858
implement_spanned!(ast::Item);
5959
implement_spanned!(ast::Local);
@@ -143,7 +143,7 @@ impl Spanned for ast::GenericParam {
143143
}
144144
}
145145

146-
impl Spanned for ast::StructField {
146+
impl Spanned for ast::FieldDef {
147147
fn span(&self) -> Span {
148148
span_with_attrs_lo_hi!(self, self.span.lo(), self.ty.span.hi())
149149
}

src/vertical.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(crate) trait AlignedItem {
3333
) -> Option<String>;
3434
}
3535

36-
impl AlignedItem for ast::StructField {
36+
impl AlignedItem for ast::FieldDef {
3737
fn skip(&self) -> bool {
3838
contains_skip(&self.attrs)
3939
}
@@ -72,7 +72,7 @@ impl AlignedItem for ast::StructField {
7272
}
7373
}
7474

75-
impl AlignedItem for ast::Field {
75+
impl AlignedItem for ast::ExprField {
7676
fn skip(&self) -> bool {
7777
contains_skip(&self.attrs)
7878
}

0 commit comments

Comments
 (0)