Skip to content

Commit 4e8ed17

Browse files
upgrade rustc-ap-* version to v642 (#4022)
1 parent facba6a commit 4e8ed17

36 files changed

+673
-424
lines changed

Cargo.lock

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

rustfmt-core/rustfmt-config/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ serde_json = "1.0"
1717
thiserror = "1.0"
1818
toml = "0.5"
1919

20-
[dependencies.syntax_pos]
21-
package = "rustc-ap-syntax_pos"
22-
version = "610.0.0"
20+
[dependencies.rustc_span]
21+
package = "rustc-ap-rustc_span"
22+
version = "642.0.0"
2323

rustfmt-core/rustfmt-config/src/file_lines.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use serde::{ser, Deserialize, Deserializer, Serialize, Serializer};
1010
use serde_json as json;
1111
use thiserror::Error;
1212

13-
use syntax_pos::{self, SourceFile};
13+
use rustc_span::{self, SourceFile};
1414

1515
/// A range of lines in a file, inclusive of both ends.
1616
pub struct LineRange {
@@ -26,21 +26,21 @@ pub enum FileName {
2626
Stdin,
2727
}
2828

29-
impl From<syntax_pos::FileName> for FileName {
30-
fn from(name: syntax_pos::FileName) -> FileName {
29+
impl From<rustc_span::FileName> for FileName {
30+
fn from(name: rustc_span::FileName) -> FileName {
3131
match name {
32-
syntax_pos::FileName::Real(p) => FileName::Real(p),
33-
syntax_pos::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
32+
rustc_span::FileName::Real(p) => FileName::Real(p),
33+
rustc_span::FileName::Custom(ref f) if f == "stdin" => FileName::Stdin,
3434
_ => unreachable!(),
3535
}
3636
}
3737
}
3838

39-
impl From<&FileName> for syntax_pos::FileName {
40-
fn from(filename: &FileName) -> syntax_pos::FileName {
39+
impl From<&FileName> for rustc_span::FileName {
40+
fn from(filename: &FileName) -> rustc_span::FileName {
4141
match filename {
42-
FileName::Real(path) => syntax_pos::FileName::Real(path.to_owned()),
43-
FileName::Stdin => syntax_pos::FileName::Custom("stdin".to_owned()),
42+
FileName::Real(path) => rustc_span::FileName::Real(path.to_owned()),
43+
FileName::Stdin => rustc_span::FileName::Custom("stdin".to_owned()),
4444
}
4545
}
4646
}

rustfmt-core/rustfmt-config/src/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl Default for Edition {
374374
}
375375
}
376376

377-
impl From<Edition> for syntax_pos::edition::Edition {
377+
impl From<Edition> for rustc_span::edition::Edition {
378378
fn from(edition: Edition) -> Self {
379379
match edition {
380380
Edition::Edition2015 => Self::Edition2015,

rustfmt-core/rustfmt-lib/Cargo.toml

+26-10
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,35 @@ unicode-width = "0.1.5"
3030
[dev-dependencies]
3131
env_logger = "0.7"
3232

33+
[dependencies.rustc_ast_pretty]
34+
package = "rustc-ap-rustc_ast_pretty"
35+
version = "642.0.0"
36+
37+
[dependencies.rustc_data_structures]
38+
package = "rustc-ap-rustc_data_structures"
39+
version = "642.0.0"
40+
41+
[dependencies.rustc_errors]
42+
package = "rustc-ap-rustc_errors"
43+
version = "642.0.0"
44+
45+
[dependencies.rustc_parse]
46+
package = "rustc-ap-rustc_parse"
47+
version = "642.0.0"
48+
49+
[dependencies.rustc_session]
50+
package = "rustc-ap-rustc_session"
51+
version = "642.0.0"
52+
53+
[dependencies.rustc_span]
54+
package = "rustc-ap-rustc_span"
55+
version = "642.0.0"
56+
3357
[dependencies.rustc_target]
3458
package = "rustc-ap-rustc_target"
35-
version = "610.0.0"
59+
version = "642.0.0"
3660

3761
[dependencies.syntax]
3862
package = "rustc-ap-syntax"
39-
version = "610.0.0"
40-
41-
[dependencies.syntax_pos]
42-
package = "rustc-ap-syntax_pos"
43-
version = "610.0.0"
44-
45-
[dependencies.rustc_data_structures]
46-
package = "rustc-ap-rustc_data_structures"
47-
version = "610.0.0"
63+
version = "642.0.0"
4864

rustfmt-core/rustfmt-lib/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::{BytePos, DUMMY_SP, Span, symbol::sym};
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);

rustfmt-core/rustfmt-lib/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};

rustfmt-core/rustfmt-lib/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;
@@ -184,7 +184,7 @@ fn rewrite_closure_expr(
184184
| ast::ExprKind::Loop(..)
185185
| ast::ExprKind::Struct(..) => true,
186186

187-
ast::ExprKind::AddrOf(_, ref expr)
187+
ast::ExprKind::AddrOf(_, _, ref expr)
188188
| ast::ExprKind::Box(ref expr)
189189
| ast::ExprKind::Try(ref expr)
190190
| ast::ExprKind::Unary(_, ref expr)
@@ -431,7 +431,7 @@ fn is_block_closure_forced_inner(expr: &ast::Expr) -> bool {
431431
| ast::ExprKind::While(..)
432432
| ast::ExprKind::ForLoop(..)
433433
| ast::ExprKind::Loop(..) => true,
434-
ast::ExprKind::AddrOf(_, ref expr)
434+
ast::ExprKind::AddrOf(_, _, ref expr)
435435
| ast::ExprKind::Box(ref expr)
436436
| ast::ExprKind::Try(ref expr)
437437
| ast::ExprKind::Unary(_, ref expr)

rustfmt-core/rustfmt-lib/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;

rustfmt-core/rustfmt-lib/src/expr.rs

+19-14
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, Span};
5+
use rustc_span::{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,
@@ -1289,7 +1289,7 @@ pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
12891289
match expr.kind {
12901290
ast::ExprKind::Lit(..) => true,
12911291
ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1,
1292-
ast::ExprKind::AddrOf(_, ref expr)
1292+
ast::ExprKind::AddrOf(_, _, ref expr)
12931293
| ast::ExprKind::Box(ref expr)
12941294
| ast::ExprKind::Cast(ref expr, _)
12951295
| ast::ExprKind::Field(ref expr, _)
@@ -1335,8 +1335,12 @@ pub(crate) fn can_be_overflowed_expr(
13351335
|| (context.use_block_indent() && args_len == 1)
13361336
}
13371337
ast::ExprKind::Mac(ref mac) => {
1338-
match (mac.delim, context.config.overflow_delimited_expr()) {
1339-
(ast::MacDelimiter::Bracket, true) | (ast::MacDelimiter::Brace, true) => true,
1338+
match (
1339+
syntax::ast::MacDelimiter::from_token(mac.args.delim()),
1340+
context.config.overflow_delimited_expr(),
1341+
) {
1342+
(Some(ast::MacDelimiter::Bracket), true)
1343+
| (Some(ast::MacDelimiter::Brace), true) => true,
13401344
_ => context.use_block_indent() && args_len == 1,
13411345
}
13421346
}
@@ -1347,7 +1351,7 @@ pub(crate) fn can_be_overflowed_expr(
13471351
}
13481352

13491353
// Handle unary-like expressions
1350-
ast::ExprKind::AddrOf(_, ref expr)
1354+
ast::ExprKind::AddrOf(_, _, ref expr)
13511355
| ast::ExprKind::Box(ref expr)
13521356
| ast::ExprKind::Try(ref expr)
13531357
| ast::ExprKind::Unary(_, ref expr)
@@ -1359,7 +1363,7 @@ pub(crate) fn can_be_overflowed_expr(
13591363
pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool {
13601364
match expr.kind {
13611365
ast::ExprKind::Call(..) | ast::ExprKind::Mac(..) => true,
1362-
ast::ExprKind::AddrOf(_, ref expr)
1366+
ast::ExprKind::AddrOf(_, _, ref expr)
13631367
| ast::ExprKind::Box(ref expr)
13641368
| ast::ExprKind::Try(ref expr)
13651369
| ast::ExprKind::Unary(_, ref expr)
@@ -2035,21 +2039,22 @@ pub(crate) fn prefer_next_line(
20352039

20362040
fn rewrite_expr_addrof(
20372041
context: &RewriteContext<'_>,
2042+
_borrow_kind: ast::BorrowKind,
20382043
mutability: ast::Mutability,
20392044
expr: &ast::Expr,
20402045
shape: Shape,
20412046
) -> Option<String> {
20422047
let operator_str = match mutability {
2043-
ast::Mutability::Immutable => "&",
2044-
ast::Mutability::Mutable => "&mut ",
2048+
ast::Mutability::Not => "&",
2049+
ast::Mutability::Mut => "&mut ",
20452050
};
20462051
rewrite_unary_prefix(context, operator_str, expr, shape)
20472052
}
20482053

20492054
pub(crate) fn is_method_call(expr: &ast::Expr) -> bool {
20502055
match expr.kind {
20512056
ast::ExprKind::MethodCall(..) => true,
2052-
ast::ExprKind::AddrOf(_, ref expr)
2057+
ast::ExprKind::AddrOf(_, _, ref expr)
20532058
| ast::ExprKind::Box(ref expr)
20542059
| ast::ExprKind::Cast(ref expr, _)
20552060
| ast::ExprKind::Try(ref expr)

rustfmt-core/rustfmt-lib/src/formatting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::collections::HashMap;
44
use std::io::{self, Write};
55
use std::time::{Duration, Instant};
66

7+
use rustc_span::Span;
78
use syntax::ast;
8-
use syntax::source_map::Span;
99

1010
use self::newline_style::apply_newline_style;
1111
use crate::comment::{CharClasses, FullCodeCharKind};
@@ -93,7 +93,7 @@ fn format_project<T: FormatHandler>(
9393
let mut context = FormatContext::new(&krate, report, parse_session, config, handler);
9494
let files = modules::ModResolver::new(
9595
&context.parse_session,
96-
directory_ownership.unwrap_or(DirectoryOwnership::UnownedViaMod(true)),
96+
directory_ownership.unwrap_or(DirectoryOwnership::UnownedViaMod),
9797
!input_is_stdin && config.recursive(),
9898
)
9999
.visit_crate(&krate)

rustfmt-core/rustfmt-lib/src/imports.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::borrow::Cow;
22
use std::cmp::Ordering;
33
use std::fmt;
44

5+
use rustc_span::{BytePos, DUMMY_SP, source_map, Span, symbol::sym};
56
use syntax::ast::{self, UseTreeKind};
6-
use syntax::source_map::{self, BytePos, Span, DUMMY_SP};
7-
use syntax::symbol::sym;
87

98
use crate::comment::combine_strs_with_missing_comments;
109
use crate::config::lists::*;
@@ -249,7 +248,7 @@ impl UseTree {
249248

250249
let allow_extend = if attrs.len() == 1 {
251250
let line_len = attr_str.len() + 1 + use_str.len();
252-
!attrs.first().unwrap().is_sugared_doc
251+
!attrs.first().unwrap().is_doc_comment()
253252
&& context.config.inline_attribute_width() >= line_len
254253
} else {
255254
false
@@ -854,7 +853,7 @@ impl Rewrite for UseTree {
854853
#[cfg(test)]
855854
mod test {
856855
use super::*;
857-
use syntax::source_map::DUMMY_SP;
856+
use rustc_span::DUMMY_SP;
858857

859858
// Parse the path part of an import. This parser is not robust and is only
860859
// suitable for use in a test harness.

0 commit comments

Comments
 (0)