deps: apply rustc-ap-* v712 changes
This commit is contained in:
parent
ef57c5bf67
commit
4948911608
29
src/expr.rs
29
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> {
|
||||
|
12
src/items.rs
12
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> {
|
||||
|
@ -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>(
|
||||
|
@ -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()
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user