Skip to content

Commit 686bee8

Browse files
deps: apply rustc-ap-* v712 changes
1 parent 151c82e commit 686bee8

File tree

6 files changed

+33
-30
lines changed

6 files changed

+33
-30
lines changed

src/formatting/expr.rs

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

1545-
fn struct_lit_can_be_aligned(fields: &[ast::Field], has_base: bool) -> bool {
1548+
fn struct_lit_can_be_aligned(fields: &[ast::ExprField], has_base: bool) -> bool {
15461549
!has_base && fields.iter().all(|field| !field.is_shorthand)
15471550
}
15481551

15491552
fn rewrite_struct_lit<'a>(
15501553
context: &RewriteContext<'_>,
15511554
path: &ast::Path,
1552-
fields: &'a [ast::Field],
1555+
fields: &'a [ast::ExprField],
15531556
struct_rest: &ast::StructRest,
15541557
attrs: &[ast::Attribute],
15551558
span: Span,
@@ -1558,7 +1561,7 @@ fn rewrite_struct_lit<'a>(
15581561
debug!("rewrite_struct_lit: shape {:?}", shape);
15591562

15601563
enum StructLitField<'a> {
1561-
Regular(&'a ast::Field),
1564+
Regular(&'a ast::ExprField),
15621565
Base(&'a ast::Expr),
15631566
Rest(&'a Span),
15641567
}
@@ -1715,7 +1718,7 @@ pub(crate) fn struct_lit_field_separator(config: &Config) -> &str {
17151718

17161719
pub(crate) fn rewrite_field(
17171720
context: &RewriteContext<'_>,
1718-
field: &ast::Field,
1721+
field: &ast::ExprField,
17191722
shape: Shape,
17201723
prefix_max_width: usize,
17211724
) -> Option<String> {

src/formatting/items.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'a> Item<'a> {
213213
#[derive(Debug)]
214214
enum BodyElement<'a> {
215215
// Stmt(&'a ast::Stmt),
216-
// Field(&'a ast::Field),
216+
// Field(&'a ast::ExprField),
217217
// Variant(&'a ast::Variant),
218218
// Item(&'a ast::Item),
219219
ForeignItem(&'a ast::ForeignItem),
@@ -1377,7 +1377,7 @@ fn format_unit_struct(
13771377
pub(crate) fn format_struct_struct(
13781378
context: &RewriteContext<'_>,
13791379
struct_parts: &StructParts<'_>,
1380-
fields: &[ast::StructField],
1380+
fields: &[ast::FieldDef],
13811381
offset: Indent,
13821382
one_line_width: Option<usize>,
13831383
) -> Option<String> {
@@ -1521,7 +1521,7 @@ fn format_empty_struct_or_tuple(
15211521
fn format_tuple_struct(
15221522
context: &RewriteContext<'_>,
15231523
struct_parts: &StructParts<'_>,
1524-
fields: &[ast::StructField],
1524+
fields: &[ast::FieldDef],
15251525
offset: Indent,
15261526
) -> Option<String> {
15271527
let mut result = String::with_capacity(1024);
@@ -1741,7 +1741,7 @@ fn type_annotation_spacing(config: &Config) -> (&str, &str) {
17411741

17421742
pub(crate) fn rewrite_struct_field_prefix(
17431743
context: &RewriteContext<'_>,
1744-
field: &ast::StructField,
1744+
field: &ast::FieldDef,
17451745
) -> String {
17461746
let vis = format_visibility(context, &field.vis);
17471747
let type_annotation_spacing = type_annotation_spacing(context.config);
@@ -1756,15 +1756,15 @@ pub(crate) fn rewrite_struct_field_prefix(
17561756
}
17571757
}
17581758

1759-
impl Rewrite for ast::StructField {
1759+
impl Rewrite for ast::FieldDef {
17601760
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
17611761
rewrite_struct_field(context, self, shape, 0)
17621762
}
17631763
}
17641764

17651765
pub(crate) fn rewrite_struct_field(
17661766
context: &RewriteContext<'_>,
1767-
field: &ast::StructField,
1767+
field: &ast::FieldDef,
17681768
shape: Shape,
17691769
lhs_max_width: usize,
17701770
) -> Option<String> {

src/formatting/overflow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub(crate) enum OverflowableItem<'a> {
7676
MacroArg(&'a MacroArg),
7777
NestedMetaItem(&'a ast::NestedMetaItem),
7878
SegmentParam(&'a SegmentParam<'a>),
79-
StructField(&'a ast::StructField),
79+
FieldDef(&'a ast::FieldDef),
8080
TuplePatField(&'a TuplePatField<'a>),
8181
Ty(&'a ast::Ty),
8282
}
@@ -98,7 +98,7 @@ impl<'a> OverflowableItem<'a> {
9898
match self {
9999
OverflowableItem::Expr(ast::Expr { attrs, .. })
100100
| OverflowableItem::GenericParam(ast::GenericParam { attrs, .. }) => !attrs.is_empty(),
101-
OverflowableItem::StructField(ast::StructField { attrs, .. }) => !attrs.is_empty(),
101+
OverflowableItem::FieldDef(ast::FieldDef { attrs, .. }) => !attrs.is_empty(),
102102
OverflowableItem::MacroArg(MacroArg::Expr(expr)) => !expr.attrs.is_empty(),
103103
OverflowableItem::MacroArg(MacroArg::Item(item)) => !item.attrs.is_empty(),
104104
_ => false,
@@ -115,7 +115,7 @@ impl<'a> OverflowableItem<'a> {
115115
OverflowableItem::MacroArg(macro_arg) => f(*macro_arg),
116116
OverflowableItem::NestedMetaItem(nmi) => f(*nmi),
117117
OverflowableItem::SegmentParam(sp) => f(*sp),
118-
OverflowableItem::StructField(sf) => f(*sf),
118+
OverflowableItem::FieldDef(sf) => f(*sf),
119119
OverflowableItem::TuplePatField(pat) => f(*pat),
120120
OverflowableItem::Ty(ty) => f(*ty),
121121
}
@@ -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/formatting/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

@@ -261,7 +261,7 @@ impl Rewrite for Pat {
261261

262262
fn rewrite_struct_pat(
263263
path: &ast::Path,
264-
fields: &[ast::FieldPat],
264+
fields: &[ast::PatField],
265265
ellipsis: bool,
266266
span: Span,
267267
context: &RewriteContext<'_>,
@@ -336,7 +336,7 @@ fn rewrite_struct_pat(
336336
Some(format!("{} {{{}}}", path_str, fields_str))
337337
}
338338

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

src/formatting/spanned.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ macro_rules! implement_spanned {
5656
// Implement `Spanned` for structs with `attrs` field.
5757
implement_spanned!(ast::AssocItem);
5858
implement_spanned!(ast::Expr);
59-
implement_spanned!(ast::Field);
59+
implement_spanned!(ast::ExprField);
6060
implement_spanned!(ast::ForeignItem);
6161
implement_spanned!(ast::Item);
6262
implement_spanned!(ast::Local);
@@ -146,7 +146,7 @@ impl Spanned for ast::GenericParam {
146146
}
147147
}
148148

149-
impl Spanned for ast::StructField {
149+
impl Spanned for ast::FieldDef {
150150
fn span(&self) -> Span {
151151
span_with_attrs_lo_hi!(self, self.span.lo(), self.ty.span.hi())
152152
}

src/formatting/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
}
@@ -71,7 +71,7 @@ impl AlignedItem for ast::StructField {
7171
}
7272
}
7373

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

0 commit comments

Comments
 (0)