Skip to content

Commit 9f53665

Browse files
authored
rustfmt 1.x bump rustc-ap to v642 (#4043)
2 parents 1838235 + 760bb29 commit 9f53665

34 files changed

+953
-476
lines changed

Diff for: Cargo.lock

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

Diff for: Cargo.toml

+28-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "rustfmt-nightly"
4-
version = "1.4.11"
4+
version = "1.4.12"
55
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
66
description = "Tool to find and fix Rust formatting issues"
77
repository = "https://github.com/rust-lang/rustfmt"
@@ -52,7 +52,7 @@ bytecount = "0.6"
5252
unicode-width = "0.1.5"
5353
unicode_categories = "0.1.1"
5454
dirs = "2.0.1"
55-
ignore = "0.4.6"
55+
ignore = "0.4.11"
5656
annotate-snippets = { version = "0.6", features = ["ansi_term"] }
5757
structopt = "0.3"
5858
rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
@@ -62,17 +62,37 @@ rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }
6262
# for more information.
6363
rustc-workspace-hack = "1.0.0"
6464

65+
[dependencies.rustc_ast_pretty]
66+
package = "rustc-ap-rustc_ast_pretty"
67+
version = "642.0.0"
68+
69+
[dependencies.rustc_data_structures]
70+
package = "rustc-ap-rustc_data_structures"
71+
version = "642.0.0"
72+
73+
[dependencies.rustc_errors]
74+
package = "rustc-ap-rustc_errors"
75+
version = "642.0.0"
76+
77+
[dependencies.rustc_parse]
78+
package = "rustc-ap-rustc_parse"
79+
version = "642.0.0"
80+
81+
[dependencies.rustc_session]
82+
package = "rustc-ap-rustc_session"
83+
version = "642.0.0"
84+
85+
[dependencies.rustc_span]
86+
package = "rustc-ap-rustc_span"
87+
version = "642.0.0"
88+
6589
[dependencies.rustc_target]
6690
package = "rustc-ap-rustc_target"
67-
version = "610.0.0"
91+
version = "642.0.0"
6892

6993
[dependencies.syntax]
7094
package = "rustc-ap-syntax"
71-
version = "610.0.0"
72-
73-
[dependencies.syntax_pos]
74-
package = "rustc-ap-syntax_pos"
75-
version = "610.0.0"
95+
version = "642.0.0"
7696

7797
[dev-dependencies]
7898
lazy_static = "1.0.0"

Diff for: src/attr.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Format attributes and meta items.
22
3+
use rustc_span::{symbol::sym, BytePos, Span, DUMMY_SP};
34
use syntax::ast;
4-
use syntax::source_map::{BytePos, Span, DUMMY_SP};
5-
use syntax::symbol::sym;
65

76
use self::doc_comment::DocCommentFormatter;
87
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};
@@ -35,7 +34,7 @@ pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
3534
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => expr.span,
3635
ast::StmtKind::Mac(ref mac) => {
3736
let (ref mac, _, _) = **mac;
38-
mac.span
37+
mac.span()
3938
}
4039
}
4140
}
@@ -168,7 +167,7 @@ fn rewrite_initial_doc_comments(
168167
return Some((0, None));
169168
}
170169
// Rewrite doc comments
171-
let sugared_docs = take_while_with_pred(context, attrs, |a| a.is_sugared_doc);
170+
let sugared_docs = take_while_with_pred(context, attrs, |a| a.is_doc_comment());
172171
if !sugared_docs.is_empty() {
173172
let snippet = sugared_docs
174173
.iter()
@@ -316,7 +315,7 @@ where
316315
impl Rewrite for ast::Attribute {
317316
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
318317
let snippet = context.snippet(self.span);
319-
if self.is_sugared_doc {
318+
if self.is_doc_comment() {
320319
rewrite_doc_comment(snippet, shape.comment(context.config), context.config)
321320
} else {
322321
let should_skip = self
@@ -438,7 +437,7 @@ impl<'a> Rewrite for [ast::Attribute] {
438437
)?;
439438
result.push_str(&comment);
440439
if let Some(next) = attrs.get(derives.len()) {
441-
if next.is_sugared_doc {
440+
if next.is_doc_comment() {
442441
let snippet = context.snippet(missing_span);
443442
let (_, mlb) = has_newlines_before_after_comment(snippet);
444443
result.push_str(&mlb);
@@ -471,7 +470,7 @@ impl<'a> Rewrite for [ast::Attribute] {
471470
)?;
472471
result.push_str(&comment);
473472
if let Some(next) = attrs.get(1) {
474-
if next.is_sugared_doc {
473+
if next.is_doc_comment() {
475474
let snippet = context.snippet(missing_span);
476475
let (_, mlb) = has_newlines_before_after_comment(snippet);
477476
result.push_str(&mlb);

Diff for: src/chains.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
use std::borrow::Cow;
5959
use std::cmp::min;
6060

61-
use syntax::source_map::{BytePos, Span};
61+
use rustc_span::{BytePos, Span};
6262
use syntax::{ast, ptr};
6363

6464
use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};

Diff for: src/closures.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use syntax::source_map::Span;
1+
use rustc_span::Span;
22
use syntax::{ast, ptr};
33

44
use crate::attr::get_attrs_from_stmt;
@@ -176,7 +176,7 @@ fn rewrite_closure_expr(
176176
| ast::ExprKind::Loop(..)
177177
| ast::ExprKind::Struct(..) => true,
178178

179-
ast::ExprKind::AddrOf(_, ref expr)
179+
ast::ExprKind::AddrOf(_, _, ref expr)
180180
| ast::ExprKind::Box(ref expr)
181181
| ast::ExprKind::Try(ref expr)
182182
| ast::ExprKind::Unary(_, ref expr)
@@ -382,7 +382,7 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
382382
match expr.kind {
383383
ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true,
384384
ast::ExprKind::Loop(..) if version == Version::Two => true,
385-
ast::ExprKind::AddrOf(_, ref expr)
385+
ast::ExprKind::AddrOf(_, _, ref expr)
386386
| ast::ExprKind::Box(ref expr)
387387
| ast::ExprKind::Try(ref expr)
388388
| ast::ExprKind::Unary(_, ref expr)

Diff for: src/comment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{self, borrow::Cow, iter};
44

55
use itertools::{multipeek, MultiPeek};
6-
use syntax::source_map::Span;
6+
use rustc_span::Span;
77

88
use crate::config::Config;
99
use crate::rewrite::RewriteContext;

Diff for: src/config/file_lines.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ use std::path::PathBuf;
66
use std::rc::Rc;
77
use std::{cmp, fmt, iter, str};
88

9+
use rustc_span::{self, SourceFile};
910
use serde::{ser, Deserialize, Deserializer, Serialize, Serializer};
1011
use serde_json as json;
1112

12-
use syntax::source_map::{self, SourceFile};
13-
1413
/// A range of lines in a file, inclusive of both ends.
1514
pub struct LineRange {
1615
pub file: Rc<SourceFile>,
@@ -25,11 +24,11 @@ pub enum FileName {
2524
Stdin,
2625
}
2726

28-
impl From<source_map::FileName> for FileName {
29-
fn from(name: source_map::FileName) -> FileName {
27+
impl From<rustc_span::FileName> for FileName {
28+
fn from(name: rustc_span::FileName) -> FileName {
3029
match name {
31-
source_map::FileName::Real(p) => FileName::Real(p),
32-
source_map::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
30+
rustc_span::FileName::Real(p) => FileName::Real(p),
31+
rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
3332
_ => unreachable!(),
3433
}
3534
}

Diff for: src/config/options.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ impl Default for Edition {
385385
}
386386

387387
impl Edition {
388-
pub(crate) fn to_libsyntax_pos_edition(self) -> syntax_pos::edition::Edition {
388+
pub(crate) fn to_libsyntax_pos_edition(self) -> rustc_span::edition::Edition {
389389
match self {
390-
Edition::Edition2015 => syntax_pos::edition::Edition::Edition2015,
391-
Edition::Edition2018 => syntax_pos::edition::Edition::Edition2018,
390+
Edition::Edition2015 => rustc_span::edition::Edition::Edition2015,
391+
Edition::Edition2018 => rustc_span::edition::Edition::Edition2018,
392392
}
393393
}
394394
}

Diff for: src/expr.rs

+21-16
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::borrow::Cow;
22
use std::cmp::min;
33

44
use itertools::Itertools;
5-
use syntax::parse::token::{DelimToken, LitKind};
6-
use syntax::source_map::{BytePos, SourceMap, Span};
5+
use rustc_span::{source_map::SourceMap, BytePos, Span};
6+
use syntax::token::{DelimToken, LitKind};
77
use syntax::{ast, ptr};
88

99
use crate::chains::rewrite_chain;
@@ -159,7 +159,7 @@ pub(crate) fn format_expr(
159159
ast::ExprKind::Path(ref qself, ref path) => {
160160
rewrite_path(context, PathContext::Expr, qself.as_ref(), path, shape)
161161
}
162-
ast::ExprKind::Assign(ref lhs, ref rhs) => {
162+
ast::ExprKind::Assign(ref lhs, ref rhs, _) => {
163163
rewrite_assignment(context, lhs, rhs, None, shape)
164164
}
165165
ast::ExprKind::AssignOp(ref op, ref lhs, ref rhs) => {
@@ -213,8 +213,8 @@ pub(crate) fn format_expr(
213213
rewrite_unary_prefix(context, "return ", &**expr, shape)
214214
}
215215
ast::ExprKind::Box(ref expr) => rewrite_unary_prefix(context, "box ", &**expr, shape),
216-
ast::ExprKind::AddrOf(mutability, ref expr) => {
217-
rewrite_expr_addrof(context, mutability, expr, shape)
216+
ast::ExprKind::AddrOf(borrow_kind, mutability, ref expr) => {
217+
rewrite_expr_addrof(context, borrow_kind, mutability, expr, shape)
218218
}
219219
ast::ExprKind::Cast(ref expr, ref ty) => rewrite_pair(
220220
&**expr,
@@ -252,7 +252,7 @@ pub(crate) fn format_expr(
252252
fn needs_space_before_range(context: &RewriteContext<'_>, lhs: &ast::Expr) -> bool {
253253
match lhs.kind {
254254
ast::ExprKind::Lit(ref lit) => match lit.kind {
255-
ast::LitKind::FloatUnsuffixed(..) => {
255+
ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) => {
256256
context.snippet(lit.span).ends_with('.')
257257
}
258258
_ => false,
@@ -1148,10 +1148,10 @@ pub(crate) fn is_simple_block(
11481148
attrs: Option<&[ast::Attribute]>,
11491149
source_map: &SourceMap,
11501150
) -> bool {
1151-
(block.stmts.len() == 1
1151+
block.stmts.len() == 1
11521152
&& stmt_is_expr(&block.stmts[0])
11531153
&& !block_contains_comment(block, source_map)
1154-
&& attrs.map_or(true, |a| a.is_empty()))
1154+
&& attrs.map_or(true, |a| a.is_empty())
11551155
}
11561156

11571157
/// Checks whether a block contains at most one statement or expression, and no
@@ -1268,7 +1268,7 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
12681268
match expr.kind {
12691269
ast::ExprKind::Lit(..) => true,
12701270
ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1,
1271-
ast::ExprKind::AddrOf(_, ref expr)
1271+
ast::ExprKind::AddrOf(_, _, ref expr)
12721272
| ast::ExprKind::Box(ref expr)
12731273
| ast::ExprKind::Cast(ref expr, _)
12741274
| ast::ExprKind::Field(ref expr, _)
@@ -1314,8 +1314,12 @@ pub(crate) fn can_be_overflowed_expr(
13141314
|| (context.use_block_indent() && args_len == 1)
13151315
}
13161316
ast::ExprKind::Mac(ref mac) => {
1317-
match (mac.delim, context.config.overflow_delimited_expr()) {
1318-
(ast::MacDelimiter::Bracket, true) | (ast::MacDelimiter::Brace, true) => true,
1317+
match (
1318+
syntax::ast::MacDelimiter::from_token(mac.args.delim()),
1319+
context.config.overflow_delimited_expr(),
1320+
) {
1321+
(Some(ast::MacDelimiter::Bracket), true)
1322+
| (Some(ast::MacDelimiter::Brace), true) => true,
13191323
_ => context.use_block_indent() && args_len == 1,
13201324
}
13211325
}
@@ -1326,7 +1330,7 @@ pub(crate) fn can_be_overflowed_expr(
13261330
}
13271331

13281332
// Handle unary-like expressions
1329-
ast::ExprKind::AddrOf(_, ref expr)
1333+
ast::ExprKind::AddrOf(_, _, ref expr)
13301334
| ast::ExprKind::Box(ref expr)
13311335
| ast::ExprKind::Try(ref expr)
13321336
| ast::ExprKind::Unary(_, ref expr)
@@ -1338,7 +1342,7 @@ pub(crate) fn can_be_overflowed_expr(
13381342
pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool {
13391343
match expr.kind {
13401344
ast::ExprKind::Call(..) | ast::ExprKind::Mac(..) => true,
1341-
ast::ExprKind::AddrOf(_, ref expr)
1345+
ast::ExprKind::AddrOf(_, _, ref expr)
13421346
| ast::ExprKind::Box(ref expr)
13431347
| ast::ExprKind::Try(ref expr)
13441348
| ast::ExprKind::Unary(_, ref expr)
@@ -1985,21 +1989,22 @@ pub(crate) fn prefer_next_line(
19851989

19861990
fn rewrite_expr_addrof(
19871991
context: &RewriteContext<'_>,
1992+
_borrow_kind: ast::BorrowKind,
19881993
mutability: ast::Mutability,
19891994
expr: &ast::Expr,
19901995
shape: Shape,
19911996
) -> Option<String> {
19921997
let operator_str = match mutability {
1993-
ast::Mutability::Immutable => "&",
1994-
ast::Mutability::Mutable => "&mut ",
1998+
ast::Mutability::Not => "&",
1999+
ast::Mutability::Mut => "&mut ",
19952000
};
19962001
rewrite_unary_prefix(context, operator_str, expr, shape)
19972002
}
19982003

19992004
pub(crate) fn is_method_call(expr: &ast::Expr) -> bool {
20002005
match expr.kind {
20012006
ast::ExprKind::MethodCall(..) => true,
2002-
ast::ExprKind::AddrOf(_, ref expr)
2007+
ast::ExprKind::AddrOf(_, _, ref expr)
20032008
| ast::ExprKind::Box(ref expr)
20042009
| ast::ExprKind::Cast(ref expr, _)
20052010
| ast::ExprKind::Try(ref expr)

0 commit comments

Comments
 (0)