Skip to content

Commit 383306e

Browse files
authored
Update rustc-ap-* crates to 606.0.0 (rust-lang#3835)
1 parent fb01dc8 commit 383306e

22 files changed

+202
-265
lines changed

Cargo.lock

+79-150
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+12-4
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ env_logger = "0.6"
4747
getopts = "0.2"
4848
derive-new = "0.5"
4949
cargo_metadata = "0.8"
50-
rustc-ap-rustc_target = "583.0.0"
51-
rustc-ap-syntax = "583.0.0"
52-
rustc-ap-syntax_pos = "583.0.0"
5350
failure = "0.1.3"
5451
bytecount = "0.6"
5552
unicode-width = "0.1.5"
@@ -58,13 +55,24 @@ dirs = "2.0.1"
5855
ignore = "0.4.6"
5956
annotate-snippets = { version = "0.6", features = ["ansi_term"] }
6057
structopt = "0.3"
61-
6258
rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
6359

6460
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
6561
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
6662
# for more information.
6763
rustc-workspace-hack = "1.0.0"
6864

65+
[dependencies.rustc_target]
66+
package = "rustc-ap-rustc_target"
67+
version = "606.0.0"
68+
69+
[dependencies.syntax]
70+
package = "rustc-ap-syntax"
71+
version = "606.0.0"
72+
73+
[dependencies.syntax_pos]
74+
package = "rustc-ap-syntax_pos"
75+
version = "606.0.0"
76+
6977
[dev-dependencies]
7078
lazy_static = "1.0.0"

src/attr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod doc_comment;
2020

2121
/// Returns attributes on the given statement.
2222
pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
23-
match stmt.node {
23+
match stmt.kind {
2424
ast::StmtKind::Local(ref local) => &local.attrs,
2525
ast::StmtKind::Item(ref item) => &item.attrs,
2626
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => &expr.attrs,
@@ -29,7 +29,7 @@ pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
2929
}
3030

3131
pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
32-
match stmt.node {
32+
match stmt.kind {
3333
ast::StmtKind::Local(ref local) => local.span,
3434
ast::StmtKind::Item(ref item) => item.span,
3535
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => expr.span,
@@ -218,7 +218,7 @@ fn has_newlines_before_after_comment(comment: &str) -> (&str, &str) {
218218

219219
impl Rewrite for ast::MetaItem {
220220
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
221-
Some(match self.node {
221+
Some(match self.kind {
222222
ast::MetaItemKind::Word => {
223223
rewrite_path(context, PathContext::Type, None, &self.path, shape)?
224224
}
@@ -495,7 +495,7 @@ fn attr_prefix(attr: &ast::Attribute) -> &'static str {
495495

496496
pub(crate) trait MetaVisitor<'ast> {
497497
fn visit_meta_item(&mut self, meta_item: &'ast ast::MetaItem) {
498-
match meta_item.node {
498+
match meta_item.kind {
499499
ast::MetaItemKind::Word => self.visit_meta_word(meta_item),
500500
ast::MetaItemKind::List(ref list) => self.visit_meta_list(meta_item, list),
501501
ast::MetaItemKind::NameValue(ref lit) => self.visit_meta_name_value(meta_item, lit),

src/chains.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl ChainItemKind {
135135
}
136136

137137
fn is_tup_field_access(expr: &ast::Expr) -> bool {
138-
match expr.node {
138+
match expr.kind {
139139
ast::ExprKind::Field(_, ref field) => {
140140
field.name.to_string().chars().all(|c| c.is_digit(10))
141141
}
@@ -144,7 +144,7 @@ impl ChainItemKind {
144144
}
145145

146146
fn from_ast(context: &RewriteContext<'_>, expr: &ast::Expr) -> (ChainItemKind, Span) {
147-
let (kind, span) = match expr.node {
147+
let (kind, span) = match expr.kind {
148148
ast::ExprKind::MethodCall(ref segment, ref expressions) => {
149149
let types = if let Some(ref generic_args) = segment.args {
150150
if let ast::GenericArgs::AngleBracketed(ref data) = **generic_args {
@@ -262,7 +262,7 @@ impl Chain {
262262
let mut rev_children = vec![];
263263
let mut sub_tries = 0;
264264
for subexpr in &subexpr_list {
265-
match subexpr.node {
265+
match subexpr.kind {
266266
ast::ExprKind::Try(_) => sub_tries += 1,
267267
_ => {
268268
rev_children.push(ChainItem::new(context, subexpr, sub_tries));
@@ -390,7 +390,7 @@ impl Chain {
390390
// Returns the expression's subexpression, if it exists. When the subexpr
391391
// is a try! macro, we'll convert it to shorthand when the option is set.
392392
fn pop_expr_chain(expr: &ast::Expr, context: &RewriteContext<'_>) -> Option<ast::Expr> {
393-
match expr.node {
393+
match expr.kind {
394394
ast::ExprKind::MethodCall(_, ref expressions) => {
395395
Some(Self::convert_try(&expressions[0], context))
396396
}
@@ -402,7 +402,7 @@ impl Chain {
402402
}
403403

404404
fn convert_try(expr: &ast::Expr, context: &RewriteContext<'_>) -> ast::Expr {
405-
match expr.node {
405+
match expr.kind {
406406
ast::ExprKind::Mac(ref mac) if context.config.use_try_shorthand() => {
407407
if let Some(subexpr) = convert_try_mac(mac, context) {
408408
subexpr

src/closures.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub(crate) fn rewrite_closure(
4040
// 1 = space between `|...|` and body.
4141
let body_shape = shape.offset_left(extra_offset)?;
4242

43-
if let ast::ExprKind::Block(ref block, _) = body.node {
43+
if let ast::ExprKind::Block(ref block, _) = body.kind {
4444
// The body of the closure is an empty block.
4545
if block.stmts.is_empty() && !block_contains_comment(block, context.source_map) {
4646
return body
@@ -89,7 +89,7 @@ fn get_inner_expr<'a>(
8989
prefix: &str,
9090
context: &RewriteContext<'_>,
9191
) -> &'a ast::Expr {
92-
if let ast::ExprKind::Block(ref block, _) = expr.node {
92+
if let ast::ExprKind::Block(ref block, _) = expr.kind {
9393
if !needs_block(block, prefix, context) {
9494
// block.stmts.len() == 1
9595
if let Some(expr) = stmt_expr(&block.stmts[0]) {
@@ -110,7 +110,7 @@ fn needs_block(block: &ast::Block, prefix: &str, context: &RewriteContext<'_>) -
110110
}
111111

112112
fn veto_block(e: &ast::Expr) -> bool {
113-
match e.node {
113+
match e.kind {
114114
ast::ExprKind::Call(..)
115115
| ast::ExprKind::Binary(..)
116116
| ast::ExprKind::Cast(..)
@@ -141,7 +141,7 @@ fn rewrite_closure_with_block(
141141
let block = ast::Block {
142142
stmts: vec![ast::Stmt {
143143
id: ast::NodeId::root(),
144-
node: ast::StmtKind::Expr(ptr::P(body.clone())),
144+
kind: ast::StmtKind::Expr(ptr::P(body.clone())),
145145
span: body.span,
146146
}],
147147
id: ast::NodeId::root(),
@@ -161,7 +161,7 @@ fn rewrite_closure_expr(
161161
shape: Shape,
162162
) -> Option<String> {
163163
fn allow_multi_line(expr: &ast::Expr) -> bool {
164-
match expr.node {
164+
match expr.kind {
165165
ast::ExprKind::Match(..)
166166
| ast::ExprKind::Block(..)
167167
| ast::ExprKind::TryBlock(..)
@@ -291,9 +291,9 @@ pub(crate) fn rewrite_last_closure(
291291
shape: Shape,
292292
) -> Option<String> {
293293
if let ast::ExprKind::Closure(capture, ref is_async, movability, ref fn_decl, ref body, _) =
294-
expr.node
294+
expr.kind
295295
{
296-
let body = match body.node {
296+
let body = match body.kind {
297297
ast::ExprKind::Block(ref block, _)
298298
if !is_unsafe_block(block)
299299
&& !context.inside_macro()
@@ -353,7 +353,7 @@ pub(crate) fn rewrite_last_closure(
353353
pub(crate) fn args_have_many_closure(args: &[OverflowableItem<'_>]) -> bool {
354354
args.iter()
355355
.filter_map(OverflowableItem::to_expr)
356-
.filter(|expr| match expr.node {
356+
.filter(|expr| match expr.kind {
357357
ast::ExprKind::Closure(..) => true,
358358
_ => false,
359359
})
@@ -371,7 +371,7 @@ fn is_block_closure_forced(context: &RewriteContext<'_>, expr: &ast::Expr) -> bo
371371
}
372372

373373
fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
374-
match expr.node {
374+
match expr.kind {
375375
ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true,
376376
ast::ExprKind::Loop(..) if version == Version::Two => true,
377377
ast::ExprKind::AddrOf(_, ref expr)
@@ -392,7 +392,7 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
392392
/// isn't parsed as (if true {...} else {...} | x) | 5
393393
// From https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/classify.rs.
394394
fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
395-
match e.node {
395+
match e.kind {
396396
ast::ExprKind::If(..)
397397
| ast::ExprKind::Match(..)
398398
| ast::ExprKind::Block(..)

src/expr.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub(crate) fn format_expr(
6565
shape
6666
};
6767

68-
let expr_rw = match expr.node {
68+
let expr_rw = match expr.kind {
6969
ast::ExprKind::Array(ref expr_vec) => rewrite_array(
7070
"",
7171
expr_vec.iter(),
@@ -250,8 +250,8 @@ pub(crate) fn format_expr(
250250
};
251251

252252
fn needs_space_before_range(context: &RewriteContext<'_>, lhs: &ast::Expr) -> bool {
253-
match lhs.node {
254-
ast::ExprKind::Lit(ref lit) => match lit.node {
253+
match lhs.kind {
254+
ast::ExprKind::Lit(ref lit) => match lit.kind {
255255
ast::LitKind::FloatUnsuffixed(..) => {
256256
context.snippet(lit.span).ends_with('.')
257257
}
@@ -262,7 +262,7 @@ pub(crate) fn format_expr(
262262
}
263263

264264
fn needs_space_after_range(rhs: &ast::Expr) -> bool {
265-
match rhs.node {
265+
match rhs.kind {
266266
// Don't format `.. ..` into `....`, which is invalid.
267267
//
268268
// This check is unnecessary for `lhs`, because a range
@@ -575,7 +575,7 @@ pub(crate) fn rewrite_cond(
575575
expr: &ast::Expr,
576576
shape: Shape,
577577
) -> Option<String> {
578-
match expr.node {
578+
match expr.kind {
579579
ast::ExprKind::Match(ref cond, _) => {
580580
// `match `cond` {`
581581
let cond_shape = match context.config.indent_style() {
@@ -612,15 +612,15 @@ struct ControlFlow<'a> {
612612
}
613613

614614
fn extract_pats_and_cond(expr: &ast::Expr) -> (Option<&ast::Pat>, &ast::Expr) {
615-
match expr.node {
615+
match expr.kind {
616616
ast::ExprKind::Let(ref pat, ref cond) => (Some(pat), cond),
617617
_ => (None, expr),
618618
}
619619
}
620620

621621
// FIXME: Refactor this.
622622
fn to_control_flow(expr: &ast::Expr, expr_type: ExprType) -> Option<ControlFlow<'_>> {
623-
match expr.node {
623+
match expr.kind {
624624
ast::ExprKind::If(ref cond, ref if_block, ref else_block) => {
625625
let (pat, cond) = extract_pats_and_cond(cond);
626626
Some(ControlFlow::new_if(
@@ -748,7 +748,7 @@ impl<'a> ControlFlow<'a> {
748748
let else_block = self.else_block?;
749749
let fixed_cost = self.keyword.len() + " { } else { }".len();
750750

751-
if let ast::ExprKind::Block(ref else_node, _) = else_block.node {
751+
if let ast::ExprKind::Block(ref else_node, _) = else_block.kind {
752752
if !is_simple_block(self.block, None, context.source_map)
753753
|| !is_simple_block(else_node, None, context.source_map)
754754
|| pat_expr_str.contains('\n')
@@ -1014,7 +1014,7 @@ impl<'a> Rewrite for ControlFlow<'a> {
10141014
if let Some(else_block) = self.else_block {
10151015
let shape = Shape::indented(shape.indent, context.config);
10161016
let mut last_in_chain = false;
1017-
let rewrite = match else_block.node {
1017+
let rewrite = match else_block.kind {
10181018
// If the else expression is another if-else expression, prevent it
10191019
// from being formatted on a single line.
10201020
// Note how we're passing the original shape, as the
@@ -1149,7 +1149,7 @@ pub(crate) fn is_empty_block(
11491149
}
11501150

11511151
pub(crate) fn stmt_is_expr(stmt: &ast::Stmt) -> bool {
1152-
match stmt.node {
1152+
match stmt.kind {
11531153
ast::StmtKind::Expr(..) => true,
11541154
_ => false,
11551155
}
@@ -1168,7 +1168,7 @@ pub(crate) fn rewrite_literal(
11681168
l: &ast::Lit,
11691169
shape: Shape,
11701170
) -> Option<String> {
1171-
match l.node {
1171+
match l.kind {
11721172
ast::LitKind::Str(_, ast::StrStyle::Cooked) => rewrite_string_lit(context, l.span, shape),
11731173
_ => wrap_str(
11741174
context.snippet(l.span).to_owned(),
@@ -1253,7 +1253,7 @@ pub(crate) fn rewrite_call(
12531253
}
12541254

12551255
pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
1256-
match expr.node {
1256+
match expr.kind {
12571257
ast::ExprKind::Lit(..) => true,
12581258
ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1,
12591259
ast::ExprKind::AddrOf(_, ref expr)
@@ -1279,7 +1279,7 @@ pub(crate) fn can_be_overflowed_expr(
12791279
expr: &ast::Expr,
12801280
args_len: usize,
12811281
) -> bool {
1282-
match expr.node {
1282+
match expr.kind {
12831283
_ if !expr.attrs.is_empty() => false,
12841284
ast::ExprKind::Match(..) => {
12851285
(context.use_block_indent() && args_len == 1)
@@ -1324,7 +1324,7 @@ pub(crate) fn can_be_overflowed_expr(
13241324
}
13251325

13261326
pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool {
1327-
match expr.node {
1327+
match expr.kind {
13281328
ast::ExprKind::Call(..) | ast::ExprKind::Mac(..) => true,
13291329
ast::ExprKind::AddrOf(_, ref expr)
13301330
| ast::ExprKind::Box(ref expr)
@@ -1380,7 +1380,7 @@ fn rewrite_paren(
13801380
post_comment = rewrite_missing_comment(post_span, shape, context)?;
13811381

13821382
// Remove nested parens if there are no comments.
1383-
if let ast::ExprKind::Paren(ref subsubexpr) = subexpr.node {
1383+
if let ast::ExprKind::Paren(ref subsubexpr) = subexpr.kind {
13841384
if remove_nested_parens && pre_comment.is_empty() && post_comment.is_empty() {
13851385
span = subexpr.span;
13861386
subexpr = subsubexpr;
@@ -1985,7 +1985,7 @@ fn rewrite_expr_addrof(
19851985
}
19861986

19871987
pub(crate) fn is_method_call(expr: &ast::Expr) -> bool {
1988-
match expr.node {
1988+
match expr.kind {
19891989
ast::ExprKind::MethodCall(..) => true,
19901990
ast::ExprKind::AddrOf(_, ref expr)
19911991
| ast::ExprKind::Box(ref expr)

src/formatting.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::time::{Duration, Instant};
88

99
use syntax::ast;
1010
use syntax::errors::emitter::{ColorConfig, Emitter};
11-
use syntax::errors::{DiagnosticBuilder, Handler};
11+
use syntax::errors::{Diagnostic, DiagnosticBuilder, Handler};
1212
use syntax::parse::{self, ParseSess};
1313
use syntax::source_map::{FilePathMapping, SourceMap, Span, DUMMY_SP};
1414

@@ -640,12 +640,6 @@ fn parse_crate(
640640
.map(|mut parser| {
641641
parser.recurse_into_file_modules = false;
642642
parser
643-
})
644-
.map_err(|diags| {
645-
diags
646-
.into_iter()
647-
.map(|d| DiagnosticBuilder::new_diagnostic(&parse_session.span_diagnostic, d))
648-
.collect::<Vec<_>>()
649643
}),
650644
};
651645

@@ -659,7 +653,13 @@ fn parse_crate(
659653
let mut parser = AssertUnwindSafe(parser);
660654
catch_unwind(move || parser.0.parse_crate_mod().map_err(|d| vec![d]))
661655
}
662-
Err(db) => Ok(Err(db)),
656+
Err(diagnostics) => {
657+
for diagnostic in diagnostics {
658+
parse_session.span_diagnostic.emit_diagnostic(&diagnostic);
659+
}
660+
report.add_parsing_error();
661+
return Err(ErrorKind::ParseError);
662+
}
663663
};
664664

665665
match result {
@@ -687,7 +687,7 @@ fn parse_crate(
687687
struct SilentEmitter;
688688

689689
impl Emitter for SilentEmitter {
690-
fn emit_diagnostic(&mut self, _db: &DiagnosticBuilder<'_>) {}
690+
fn emit_diagnostic(&mut self, _db: &Diagnostic) {}
691691
}
692692

693693
fn silent_emitter() -> Box<SilentEmitter> {

src/imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl UseTree {
287287
context: &RewriteContext<'_>,
288288
item: &ast::Item,
289289
) -> Option<UseTree> {
290-
match item.node {
290+
match item.kind {
291291
ast::ItemKind::Use(ref use_tree) => Some(
292292
UseTree::from_ast(
293293
context,

0 commit comments

Comments
 (0)