Skip to content

Commit d56d422

Browse files
committed
Cargo update
Update `rustc-ap-*` crates to 469.0.0.
1 parent c97aa15 commit d56d422

16 files changed

+299
-204
lines changed

Cargo.lock

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

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ env_logger = "0.6"
4848
getopts = "0.2"
4949
derive-new = "0.5"
5050
cargo_metadata = "0.7"
51-
rustc-ap-rustc_target = "407.0.0"
52-
rustc-ap-syntax = "407.0.0"
53-
rustc-ap-syntax_pos = "407.0.0"
51+
rustc-ap-rustc_target = "469.0.0"
52+
rustc-ap-syntax = "469.0.0"
53+
rustc-ap-syntax_pos = "469.0.0"
5454
failure = "0.1.3"
5555
bytecount = "0.5"
5656
unicode-width = "0.1.5"

src/attr.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use syntax::ast;
44
use syntax::source_map::{BytePos, Span, DUMMY_SP};
5+
use syntax::symbol::sym;
56

67
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};
78
use crate::config::lists::*;
@@ -49,15 +50,15 @@ pub(crate) fn filter_inline_attrs(
4950
}
5051

5152
fn is_derive(attr: &ast::Attribute) -> bool {
52-
attr.check_name("derive")
53+
attr.check_name(sym::derive)
5354
}
5455

5556
/// Returns the arguments of `#[derive(...)]`.
5657
fn get_derive_spans<'a>(attr: &'a ast::Attribute) -> Option<impl Iterator<Item = Span> + 'a> {
5758
attr.meta_item_list().map(|meta_item_list| {
5859
meta_item_list
5960
.into_iter()
60-
.map(|nested_meta_item| nested_meta_item.span)
61+
.map(|nested_meta_item| nested_meta_item.span())
6162
})
6263
}
6364

@@ -186,9 +187,9 @@ fn rewrite_initial_doc_comments(
186187

187188
impl Rewrite for ast::NestedMetaItem {
188189
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
189-
match self.node {
190-
ast::NestedMetaItemKind::MetaItem(ref meta_item) => meta_item.rewrite(context, shape),
191-
ast::NestedMetaItemKind::Literal(ref l) => rewrite_literal(context, l, shape),
190+
match self {
191+
ast::NestedMetaItem::MetaItem(ref meta_item) => meta_item.rewrite(context, shape),
192+
ast::NestedMetaItem::Literal(ref l) => rewrite_literal(context, l, shape),
192193
}
193194
}
194195
}
@@ -216,10 +217,10 @@ impl Rewrite for ast::MetaItem {
216217
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
217218
Some(match self.node {
218219
ast::MetaItemKind::Word => {
219-
rewrite_path(context, PathContext::Type, None, &self.ident, shape)?
220+
rewrite_path(context, PathContext::Type, None, &self.path, shape)?
220221
}
221222
ast::MetaItemKind::List(ref list) => {
222-
let path = rewrite_path(context, PathContext::Type, None, &self.ident, shape)?;
223+
let path = rewrite_path(context, PathContext::Type, None, &self.path, shape)?;
223224
let has_trailing_comma = crate::expr::span_ends_with_comma(context, self.span);
224225
overflow::rewrite_with_parens(
225226
context,
@@ -237,7 +238,7 @@ impl Rewrite for ast::MetaItem {
237238
)?
238239
}
239240
ast::MetaItemKind::NameValue(ref literal) => {
240-
let path = rewrite_path(context, PathContext::Type, None, &self.ident, shape)?;
241+
let path = rewrite_path(context, PathContext::Type, None, &self.path, shape)?;
241242
// 3 = ` = `
242243
let lit_shape = shape.shrink_left(path.len() + 3)?;
243244
// `rewrite_literal` returns `None` when `literal` exceeds max
@@ -323,7 +324,7 @@ impl Rewrite for ast::Attribute {
323324

324325
if let Some(ref meta) = self.meta() {
325326
// This attribute is possibly a doc attribute needing normalization to a doc comment
326-
if context.config.normalize_doc_attributes() && meta.check_name("doc") {
327+
if context.config.normalize_doc_attributes() && meta.check_name(sym::doc) {
327328
if let Some(ref literal) = meta.value_str() {
328329
let comment_style = match self.style {
329330
ast::AttrStyle::Inner => CommentStyle::Doc,

src/chains.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ enum ChainItemKind {
118118
),
119119
StructField(ast::Ident),
120120
TupleField(ast::Ident, bool),
121+
Await,
121122
Comment(String, CommentPosition),
122123
}
123124

@@ -128,6 +129,7 @@ impl ChainItemKind {
128129
ChainItemKind::MethodCall(..)
129130
| ChainItemKind::StructField(..)
130131
| ChainItemKind::TupleField(..)
132+
| ChainItemKind::Await
131133
| ChainItemKind::Comment(..) => false,
132134
}
133135
}
@@ -166,6 +168,10 @@ impl ChainItemKind {
166168
let span = mk_sp(nested.span.hi(), field.span.hi());
167169
(kind, span)
168170
}
171+
ast::ExprKind::Await(_, ref nested) => {
172+
let span = mk_sp(nested.span.hi(), expr.span.hi());
173+
(ChainItemKind::Await, span)
174+
}
169175
_ => return (ChainItemKind::Parent(expr.clone()), expr.span),
170176
};
171177

@@ -189,6 +195,7 @@ impl Rewrite for ChainItem {
189195
if nested { " " } else { "" },
190196
rewrite_ident(context, ident)
191197
),
198+
ChainItemKind::Await => ".await".to_owned(),
192199
ChainItemKind::Comment(ref comment, _) => {
193200
rewrite_comment(comment, false, shape, context.config)?
194201
}
@@ -387,9 +394,9 @@ impl Chain {
387394
ast::ExprKind::MethodCall(_, ref expressions) => {
388395
Some(Self::convert_try(&expressions[0], context))
389396
}
390-
ast::ExprKind::Field(ref subexpr, _) | ast::ExprKind::Try(ref subexpr) => {
391-
Some(Self::convert_try(subexpr, context))
392-
}
397+
ast::ExprKind::Field(ref subexpr, _)
398+
| ast::ExprKind::Try(ref subexpr)
399+
| ast::ExprKind::Await(_, ref subexpr) => Some(Self::convert_try(subexpr, context)),
393400
_ => None,
394401
}
395402
}

src/closures.rs

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use syntax::parse::classify;
21
use syntax::source_map::Span;
32
use syntax::{ast, ptr};
43

@@ -25,7 +24,7 @@ use crate::utils::{last_line_width, left_most_sub_expr, stmt_expr, NodeIdExt};
2524

2625
pub(crate) fn rewrite_closure(
2726
capture: ast::CaptureBy,
28-
asyncness: ast::IsAsync,
27+
is_async: &ast::IsAsync,
2928
movability: ast::Movability,
3029
fn_decl: &ast::FnDecl,
3130
body: &ast::Expr,
@@ -36,7 +35,7 @@ pub(crate) fn rewrite_closure(
3635
debug!("rewrite_closure {:?}", body);
3736

3837
let (prefix, extra_offset) = rewrite_closure_fn_decl(
39-
capture, asyncness, movability, fn_decl, body, span, context, shape,
38+
capture, is_async, movability, fn_decl, body, span, context, shape,
4039
)?;
4140
// 1 = space between `|...|` and body.
4241
let body_shape = shape.offset_left(extra_offset)?;
@@ -134,7 +133,7 @@ fn rewrite_closure_with_block(
134133
shape: Shape,
135134
) -> Option<String> {
136135
let left_most = left_most_sub_expr(body);
137-
let veto_block = veto_block(body) && !classify::expr_requires_semi_to_be_stmt(left_most);
136+
let veto_block = veto_block(body) && !expr_requires_semi_to_be_stmt(left_most);
138137
if veto_block {
139138
return None;
140139
}
@@ -207,7 +206,7 @@ fn rewrite_closure_block(
207206
// Return type is (prefix, extra_offset)
208207
fn rewrite_closure_fn_decl(
209208
capture: ast::CaptureBy,
210-
asyncness: ast::IsAsync,
209+
asyncness: &ast::IsAsync,
211210
movability: ast::Movability,
212211
fn_decl: &ast::FnDecl,
213212
body: &ast::Expr,
@@ -291,7 +290,7 @@ pub(crate) fn rewrite_last_closure(
291290
expr: &ast::Expr,
292291
shape: Shape,
293292
) -> Option<String> {
294-
if let ast::ExprKind::Closure(capture, asyncness, movability, ref fn_decl, ref body, _) =
293+
if let ast::ExprKind::Closure(capture, ref is_async, movability, ref fn_decl, ref body, _) =
295294
expr.node
296295
{
297296
let body = match body.node {
@@ -305,7 +304,7 @@ pub(crate) fn rewrite_last_closure(
305304
_ => body,
306305
};
307306
let (prefix, extra_offset) = rewrite_closure_fn_decl(
308-
capture, asyncness, movability, fn_decl, body, expr.span, context, shape,
307+
capture, is_async, movability, fn_decl, body, expr.span, context, shape,
309308
)?;
310309
// If the closure goes multi line before its body, do not overflow the closure.
311310
if prefix.contains('\n') {
@@ -387,3 +386,26 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
387386
_ => false,
388387
}
389388
}
389+
390+
/// Does this expression require a semicolon to be treated
391+
/// as a statement? The negation of this: 'can this expression
392+
/// be used as a statement without a semicolon' -- is used
393+
/// as an early-bail-out in the parser so that, for instance,
394+
/// if true {...} else {...}
395+
/// |x| 5
396+
/// isn't parsed as (if true {...} else {...} | x) | 5
397+
// From https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/classify.rs.
398+
fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
399+
match e.node {
400+
ast::ExprKind::If(..)
401+
| ast::ExprKind::IfLet(..)
402+
| ast::ExprKind::Match(..)
403+
| ast::ExprKind::Block(..)
404+
| ast::ExprKind::While(..)
405+
| ast::ExprKind::WhileLet(..)
406+
| ast::ExprKind::Loop(..)
407+
| ast::ExprKind::ForLoop(..)
408+
| ast::ExprKind::TryBlock(..) => false,
409+
_ => true,
410+
}
411+
}

src/expr.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::borrow::Cow;
22
use std::cmp::min;
3+
use std::iter;
34

45
use itertools::Itertools;
56
use syntax::parse::token::DelimToken;
@@ -182,9 +183,9 @@ pub(crate) fn format_expr(
182183
Some("yield".to_string())
183184
}
184185
}
185-
ast::ExprKind::Closure(capture, asyncness, movability, ref fn_decl, ref body, _) => {
186+
ast::ExprKind::Closure(capture, ref is_async, movability, ref fn_decl, ref body, _) => {
186187
closures::rewrite_closure(
187-
capture, asyncness, movability, fn_decl, body, expr.span, context, shape,
188+
capture, is_async, movability, fn_decl, body, expr.span, context, shape,
188189
)
189190
}
190191
ast::ExprKind::Try(..) | ast::ExprKind::Field(..) | ast::ExprKind::MethodCall(..) => {
@@ -370,6 +371,18 @@ pub(crate) fn format_expr(
370371
))
371372
}
372373
}
374+
ast::ExprKind::Await(ast::AwaitOrigin::FieldLike, _) => rewrite_chain(expr, context, shape),
375+
ast::ExprKind::Await(ast::AwaitOrigin::MacroLike, ref nested) => {
376+
overflow::rewrite_with_parens(
377+
context,
378+
"await!",
379+
iter::once(nested),
380+
shape,
381+
expr.span,
382+
context.config.max_width(),
383+
None,
384+
)
385+
}
373386
ast::ExprKind::Err => None,
374387
};
375388

src/formatting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ fn parse_crate(
687687
struct SilentEmitter;
688688

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

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

src/imports.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::fmt;
44

55
use syntax::ast::{self, UseTreeKind};
66
use syntax::source_map::{self, BytePos, Span, DUMMY_SP};
7+
use syntax::symbol::sym;
78

89
use crate::comment::combine_strs_with_missing_comments;
910
use crate::config::lists::*;
@@ -249,7 +250,7 @@ impl UseTree {
249250
match self.attrs {
250251
Some(ref attrs) if !attrs.is_empty() => {
251252
let attr_str = attrs.rewrite(context, shape)?;
252-
let lo = attrs.last().as_ref()?.span().hi();
253+
let lo = attrs.last().as_ref()?.span.hi();
253254
let hi = self.span.lo();
254255
let span = mk_sp(lo, hi);
255256

@@ -395,7 +396,7 @@ impl UseTree {
395396
rewrite_ident(context, path_to_imported_ident(&a.prefix)).to_owned()
396397
};
397398
let alias = rename.and_then(|ident| {
398-
if ident.name == "_" {
399+
if ident.name == sym::underscore_imports {
399400
// for impl-only-use
400401
Some("_".to_owned())
401402
} else if ident == path_to_imported_ident(&a.prefix) {

src/items.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub(crate) struct FnSig<'a> {
161161
decl: &'a ast::FnDecl,
162162
generics: &'a ast::Generics,
163163
abi: abi::Abi,
164-
is_async: ast::IsAsync,
164+
is_async: Cow<'a, ast::IsAsync>,
165165
constness: ast::Constness,
166166
defaultness: ast::Defaultness,
167167
unsafety: ast::Unsafety,
@@ -178,7 +178,7 @@ impl<'a> FnSig<'a> {
178178
decl,
179179
generics,
180180
abi: abi::Abi::Rust,
181-
is_async: ast::IsAsync::NotAsync,
181+
is_async: Cow::Owned(ast::IsAsync::NotAsync),
182182
constness: ast::Constness::NotConst,
183183
defaultness: ast::Defaultness::Final,
184184
unsafety: ast::Unsafety::Normal,
@@ -192,7 +192,7 @@ impl<'a> FnSig<'a> {
192192
) -> FnSig<'a> {
193193
FnSig {
194194
unsafety: method_sig.header.unsafety,
195-
is_async: method_sig.header.asyncness.node,
195+
is_async: Cow::Borrowed(&method_sig.header.asyncness.node),
196196
constness: method_sig.header.constness.node,
197197
defaultness: ast::Defaultness::Final,
198198
abi: method_sig.header.abi,
@@ -214,7 +214,7 @@ impl<'a> FnSig<'a> {
214214
generics,
215215
abi: fn_header.abi,
216216
constness: fn_header.constness.node,
217-
is_async: fn_header.asyncness.node,
217+
is_async: Cow::Borrowed(&fn_header.asyncness.node),
218218
defaultness,
219219
unsafety: fn_header.unsafety,
220220
visibility: visibility.clone(),
@@ -238,7 +238,7 @@ impl<'a> FnSig<'a> {
238238
result.push_str(format_defaultness(self.defaultness));
239239
result.push_str(format_constness(self.constness));
240240
result.push_str(format_unsafety(self.unsafety));
241-
result.push_str(format_async(self.is_async));
241+
result.push_str(format_async(&self.is_async));
242242
result.push_str(&format_abi(
243243
self.abi,
244244
context.config.force_explicit_abi(),
@@ -422,7 +422,10 @@ impl<'a> FmtVisitor<'a> {
422422
}
423423

424424
pub(crate) fn visit_struct(&mut self, struct_parts: &StructParts<'_>) {
425-
let is_tuple = struct_parts.def.is_tuple();
425+
let is_tuple = match struct_parts.def {
426+
ast::VariantData::Tuple(..) => true,
427+
_ => false,
428+
};
426429
let rewrite = format_struct(&self.get_context(), struct_parts, self.block_indent, None)
427430
.map(|s| if is_tuple { s + ";" } else { s });
428431
self.push_rewrite(struct_parts.span, rewrite);
@@ -2819,11 +2822,11 @@ impl Rewrite for ast::ForeignItem {
28192822
false,
28202823
)
28212824
.map(|(s, _)| format!("{};", s)),
2822-
ast::ForeignItemKind::Static(ref ty, is_mutable) => {
2825+
ast::ForeignItemKind::Static(ref ty, mutability) => {
28232826
// FIXME(#21): we're dropping potential comments in between the
28242827
// function keywords here.
28252828
let vis = format_visibility(context, &self.vis);
2826-
let mut_str = if is_mutable { "mut " } else { "" };
2829+
let mut_str = format_mutability(mutability);
28272830
let prefix = format!(
28282831
"{}static {}{}:",
28292832
vis,

src/matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub(crate) fn rewrite_match(
111111
.snippet_provider
112112
.span_after(mk_sp(cond.span.hi(), hi), "{")
113113
} else {
114-
inner_attrs[inner_attrs.len() - 1].span().hi()
114+
inner_attrs[inner_attrs.len() - 1].span.hi()
115115
};
116116

117117
if arms.is_empty() {

0 commit comments

Comments
 (0)