Skip to content

[1.x] bump rustc-ap crates to v712 #4775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 97 additions & 63 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 8 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,36 +66,32 @@ rustc-workspace-hack = "1.0.0"

[dependencies.rustc_ast]
package = "rustc-ap-rustc_ast"
version = "706.0.0"
version = "712.0.0"

[dependencies.rustc_ast_pretty]
package = "rustc-ap-rustc_ast_pretty"
version = "706.0.0"

[dependencies.rustc_attr]
package = "rustc-ap-rustc_attr"
version = "706.0.0"
version = "712.0.0"

[dependencies.rustc_data_structures]
package = "rustc-ap-rustc_data_structures"
version = "706.0.0"
version = "712.0.0"

[dependencies.rustc_errors]
package = "rustc-ap-rustc_errors"
version = "706.0.0"
version = "712.0.0"

[dependencies.rustc_expand]
package = "rustc-ap-rustc_expand"
version = "706.0.0"
version = "712.0.0"

[dependencies.rustc_parse]
package = "rustc-ap-rustc_parse"
version = "706.0.0"
version = "712.0.0"

[dependencies.rustc_session]
package = "rustc-ap-rustc_session"
version = "706.0.0"
version = "712.0.0"

[dependencies.rustc_span]
package = "rustc-ap-rustc_span"
version = "706.0.0"
version = "712.0.0"
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2021-02-06
nightly-2021-03-26
2 changes: 1 addition & 1 deletion src/attr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Format attributes and meta items.

use rustc_ast::ast;
use rustc_ast::attr::HasAttrs;
use rustc_ast::AstLike;
use rustc_span::{symbol::sym, Span, Symbol};

use self::doc_comment::DocCommentFormatter;
Expand Down
21 changes: 8 additions & 13 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,10 @@ 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 { fields, path, 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)
}
Expand Down Expand Up @@ -1496,14 +1491,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,
Expand All @@ -1512,7 +1507,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),
}
Expand Down Expand Up @@ -1668,7 +1663,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> {
Expand Down
4 changes: 2 additions & 2 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn format_project<T: FormatHandler>(
let mut context = FormatContext::new(&krate, report, parse_session, config, handler);
let files = modules::ModResolver::new(
&context.parse_session,
directory_ownership.unwrap_or(DirectoryOwnership::UnownedViaMod),
directory_ownership.unwrap_or(DirectoryOwnership::UnownedViaBlock),
!input_is_stdin && !config.skip_children(),
)
.visit_crate(&krate)?;
Expand Down Expand Up @@ -145,7 +145,7 @@ impl<'a, T: FormatHandler + 'a> FormatContext<'a, T> {
module: &Module<'_>,
is_macro_def: bool,
) -> Result<(), ErrorKind> {
let snippet_provider = self.parse_session.snippet_provider(module.as_ref().inner);
let snippet_provider = self.parse_session.snippet_provider(module.span);
let mut visitor = FmtVisitor::from_parse_sess(
&self.parse_session,
&self.config,
Expand Down
16 changes: 8 additions & 8 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -1646,15 +1646,15 @@ 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)
}
}

pub(crate) fn rewrite_struct_field(
context: &RewriteContext<'_>,
field: &ast::StructField,
field: &ast::FieldDef,
shape: Shape,
lhs_max_width: usize,
) -> Option<String> {
Expand Down Expand Up @@ -3271,8 +3271,8 @@ pub(crate) fn rewrite_extern_crate(
/// Returns `true` for `mod foo;`, false for `mod foo { .. }`.
pub(crate) fn is_mod_decl(item: &ast::Item) -> bool {
match item.kind {
ast::ItemKind::Mod(ref m) => m.inner.hi() != item.span.hi(),
_ => false,
ast::ItemKind::Mod(_, ast::ModKind::Loaded(_, ast::Inline::Yes, _)) => false,
_ => true,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn parse_macro_arg<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
);
parse_macro_arg!(
Pat,
|parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_pat(None),
|parser: &mut rustc_parse::parser::Parser<'b>| parser.parse_pat_no_top_alt(None),
|x: ptr::P<ast::Pat>| Some(x)
);
// `parse_item` returns `Option<ptr::P<ast::Item>>`.
Expand Down
21 changes: 9 additions & 12 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::source_map::SpanUtils;
use crate::spanned::Spanned;
use crate::utils::{
contains_skip, extra_offset, first_line_width, inner_attributes, last_line_extendable, mk_sp,
semicolon_for_expr, trimmed_last_line_width, unicode_str_width,
mk_sp_lo_plus_one, semicolon_for_expr, trimmed_last_line_width, unicode_str_width,
};

/// A simple wrapper type against `ast::Arm`. Used inside `write_list()`.
Expand Down Expand Up @@ -163,17 +163,14 @@ fn arm_comma(config: &Config, body: &ast::Expr, is_last: bool) -> &'static str {
fn collect_beginning_verts(
context: &RewriteContext<'_>,
arms: &[ast::Arm],
span: Span,
) -> Vec<Option<BytePos>> {
let mut beginning_verts = Vec::with_capacity(arms.len());
let mut lo = context.snippet_provider.span_after(span, "{");
for arm in arms {
let hi = arm.pat.span.lo();
let missing_span = mk_sp(lo, hi);
beginning_verts.push(context.snippet_provider.opt_span_before(missing_span, "|"));
lo = arm.span().hi();
}
beginning_verts
arms.iter()
.map(|a| {
context
.snippet_provider
.opt_span_before(mk_sp_lo_plus_one(a.pat.span.lo()), "|")
})
.collect()
}

fn rewrite_match_arms(
Expand All @@ -191,7 +188,7 @@ fn rewrite_match_arms(
let is_last_iter = repeat(false)
.take(arm_len.saturating_sub(1))
.chain(repeat(true));
let beginning_verts = collect_beginning_verts(context, arms, span);
let beginning_verts = collect_beginning_verts(context, arms);
let items = itemize_list(
context.snippet_provider,
arms.iter()
Expand Down
Loading