Skip to content

Commit fcc1d87

Browse files
committed
Update rustc-ap-* crates to 541.0.0
1 parent a49e474 commit fcc1d87

File tree

8 files changed

+332
-327
lines changed

8 files changed

+332
-327
lines changed

Cargo.lock

Lines changed: 295 additions & 249 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
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.8"
51-
rustc-ap-rustc_target = "491.0.0"
52-
rustc-ap-syntax = "491.0.0"
53-
rustc-ap-syntax_pos = "491.0.0"
51+
rustc-ap-rustc_target = "541.0.0"
52+
rustc-ap-syntax = "541.0.0"
53+
rustc-ap-syntax_pos = "541.0.0"
5454
failure = "0.1.3"
5555
bytecount = "0.5"
5656
unicode-width = "0.1.5"

src/closures.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,7 @@ fn is_block_closure_forced(context: &RewriteContext<'_>, expr: &ast::Expr) -> bo
372372

373373
fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
374374
match expr.node {
375-
ast::ExprKind::If(..)
376-
| ast::ExprKind::IfLet(..)
377-
| ast::ExprKind::While(..)
378-
| ast::ExprKind::WhileLet(..)
379-
| ast::ExprKind::ForLoop(..) => true,
375+
ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true,
380376
ast::ExprKind::Loop(..) if version == Version::Two => true,
381377
ast::ExprKind::AddrOf(_, ref expr)
382378
| ast::ExprKind::Box(ref expr)
@@ -398,11 +394,9 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
398394
fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
399395
match e.node {
400396
ast::ExprKind::If(..)
401-
| ast::ExprKind::IfLet(..)
402397
| ast::ExprKind::Match(..)
403398
| ast::ExprKind::Block(..)
404399
| ast::ExprKind::While(..)
405-
| ast::ExprKind::WhileLet(..)
406400
| ast::ExprKind::Loop(..)
407401
| ast::ExprKind::ForLoop(..)
408402
| ast::ExprKind::TryBlock(..) => false,

src/expr.rs

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,11 @@ pub(crate) fn format_expr(
110110
ast::ExprKind::Tup(ref items) => {
111111
rewrite_tuple(context, items.iter(), expr.span, shape, items.len() == 1)
112112
}
113+
ast::ExprKind::Let(..) => None,
113114
ast::ExprKind::If(..)
114-
| ast::ExprKind::IfLet(..)
115115
| ast::ExprKind::ForLoop(..)
116116
| ast::ExprKind::Loop(..)
117-
| ast::ExprKind::While(..)
118-
| ast::ExprKind::WhileLet(..) => to_control_flow(expr, expr_type)
117+
| ast::ExprKind::While(..) => to_control_flow(expr, expr_type)
119118
.and_then(|control_flow| control_flow.rewrite(context, shape)),
120119
ast::ExprKind::Block(ref block, opt_label) => {
121120
match expr_type {
@@ -610,21 +609,21 @@ struct ControlFlow<'a> {
610609
span: Span,
611610
}
612611

612+
fn extract_pats_and_cond(expr: &ast::Expr) -> (Vec<&ast::Pat>, &ast::Expr) {
613+
match expr.node {
614+
ast::ExprKind::Let(ref pats, ref cond) => (ptr_vec_to_ref_vec(pats), cond),
615+
_ => (vec![], expr),
616+
}
617+
}
618+
619+
// FIXME: Refactor this.
613620
fn to_control_flow(expr: &ast::Expr, expr_type: ExprType) -> Option<ControlFlow<'_>> {
614621
match expr.node {
615-
ast::ExprKind::If(ref cond, ref if_block, ref else_block) => Some(ControlFlow::new_if(
616-
cond,
617-
vec![],
618-
if_block,
619-
else_block.as_ref().map(|e| &**e),
620-
expr_type == ExprType::SubExpression,
621-
false,
622-
expr.span,
623-
)),
624-
ast::ExprKind::IfLet(ref pat, ref cond, ref if_block, ref else_block) => {
622+
ast::ExprKind::If(ref cond, ref if_block, ref else_block) => {
623+
let (pats, cond) = extract_pats_and_cond(cond);
625624
Some(ControlFlow::new_if(
626625
cond,
627-
ptr_vec_to_ref_vec(pat),
626+
pats,
628627
if_block,
629628
else_block.as_ref().map(|e| &**e),
630629
expr_type == ExprType::SubExpression,
@@ -638,16 +637,10 @@ fn to_control_flow(expr: &ast::Expr, expr_type: ExprType) -> Option<ControlFlow<
638637
ast::ExprKind::Loop(ref block, label) => {
639638
Some(ControlFlow::new_loop(block, label, expr.span))
640639
}
641-
ast::ExprKind::While(ref cond, ref block, label) => Some(ControlFlow::new_while(
642-
vec![],
643-
cond,
644-
block,
645-
label,
646-
expr.span,
647-
)),
648-
ast::ExprKind::WhileLet(ref pat, ref cond, ref block, label) => Some(
649-
ControlFlow::new_while(ptr_vec_to_ref_vec(pat), cond, block, label, expr.span),
650-
),
640+
ast::ExprKind::While(ref cond, ref block, label) => {
641+
let (pats, cond) = extract_pats_and_cond(cond);
642+
Some(ControlFlow::new_while(pats, cond, block, label, expr.span))
643+
}
651644
_ => None,
652645
}
653646
}
@@ -1020,22 +1013,11 @@ impl<'a> Rewrite for ControlFlow<'a> {
10201013
// from being formatted on a single line.
10211014
// Note how we're passing the original shape, as the
10221015
// cost of "else" should not cascade.
1023-
ast::ExprKind::IfLet(ref pat, ref cond, ref if_block, ref next_else_block) => {
1024-
ControlFlow::new_if(
1025-
cond,
1026-
ptr_vec_to_ref_vec(pat),
1027-
if_block,
1028-
next_else_block.as_ref().map(|e| &**e),
1029-
false,
1030-
true,
1031-
mk_sp(else_block.span.lo(), self.span.hi()),
1032-
)
1033-
.rewrite(context, shape)
1034-
}
10351016
ast::ExprKind::If(ref cond, ref if_block, ref next_else_block) => {
1017+
let (pats, cond) = extract_pats_and_cond(cond);
10361018
ControlFlow::new_if(
10371019
cond,
1038-
vec![],
1020+
pats,
10391021
if_block,
10401022
next_else_block.as_ref().map(|e| &**e),
10411023
false,
@@ -1332,11 +1314,9 @@ pub(crate) fn can_be_overflowed_expr(
13321314
|| context.config.overflow_delimited_expr()
13331315
}
13341316
ast::ExprKind::If(..)
1335-
| ast::ExprKind::IfLet(..)
13361317
| ast::ExprKind::ForLoop(..)
13371318
| ast::ExprKind::Loop(..)
1338-
| ast::ExprKind::While(..)
1339-
| ast::ExprKind::WhileLet(..) => {
1319+
| ast::ExprKind::While(..) => {
13401320
context.config.combine_control_expr() && context.use_block_indent() && args_len == 1
13411321
}
13421322

src/macros.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ impl MacroArgParser {
916916
break;
917917
}
918918
TokenTree::Token(ref t) => {
919-
buffer.push_str(&pprust::token_to_string(&t.kind));
919+
buffer.push_str(&pprust::token_to_string(&t));
920920
hi = t.span.hi();
921921
}
922922
_ => return None,
@@ -945,13 +945,13 @@ impl MacroArgParser {
945945
self.lo = t.span.lo();
946946
self.start_tok = t.clone();
947947
} else {
948-
let needs_space = match next_space(&self.last_tok) {
948+
let needs_space = match next_space(&self.last_tok.kind) {
949949
SpaceState::Ident => ident_like(t),
950950
SpaceState::Punctuation => !ident_like(t),
951951
SpaceState::Always => true,
952952
SpaceState::Never => false,
953953
};
954-
if force_space_before(t) || needs_space {
954+
if force_space_before(&t.kind) || needs_space {
955955
self.buf.push(' ');
956956
}
957957
}
@@ -974,7 +974,7 @@ impl MacroArgParser {
974974
}
975975
}
976976

977-
if force_space_before(&self.start_tok) {
977+
if force_space_before(&self.start_tok.kind) {
978978
return true;
979979
}
980980

@@ -1013,7 +1013,7 @@ impl MacroArgParser {
10131013
TokenTree::Token(ref t) => self.update_buffer(t),
10141014
TokenTree::Delimited(delimited_span, delimited, ref tts) => {
10151015
if !self.buf.is_empty() {
1016-
if next_space(&self.last_tok) == SpaceState::Always {
1016+
if next_space(&self.last_tok.kind) == SpaceState::Always {
10171017
self.add_separator();
10181018
} else {
10191019
self.add_other();

src/matches.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -488,18 +488,10 @@ fn rewrite_match_body(
488488
}
489489
}
490490

491-
impl Rewrite for ast::Guard {
492-
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
493-
match self {
494-
ast::Guard::If(ref expr) => expr.rewrite(context, shape),
495-
}
496-
}
497-
}
498-
499491
// The `if ...` guard on a match arm.
500492
fn rewrite_guard(
501493
context: &RewriteContext<'_>,
502-
guard: &Option<ast::Guard>,
494+
guard: &Option<ptr::P<ast::Expr>>,
503495
shape: Shape,
504496
// The amount of space used up on this line for the pattern in
505497
// the arm (excludes offset).
@@ -561,12 +553,10 @@ fn can_flatten_block_around_this(body: &ast::Expr) -> bool {
561553
match body.node {
562554
// We do not allow `if` to stay on the same line, since we could easily mistake
563555
// `pat => if cond { ... }` and `pat if cond => { ... }`.
564-
ast::ExprKind::If(..) | ast::ExprKind::IfLet(..) => false,
556+
ast::ExprKind::If(..) => false,
565557
// We do not allow collapsing a block around expression with condition
566558
// to avoid it being cluttered with match arm.
567-
ast::ExprKind::ForLoop(..) | ast::ExprKind::While(..) | ast::ExprKind::WhileLet(..) => {
568-
false
569-
}
559+
ast::ExprKind::ForLoop(..) | ast::ExprKind::While(..) => false,
570560
ast::ExprKind::Loop(..)
571561
| ast::ExprKind::Match(..)
572562
| ast::ExprKind::Block(..)

src/overflow.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,9 @@ impl<'a> Context<'a> {
414414
// When overflowing the expressions which consists of a control flow
415415
// expression, avoid condition to use multi line.
416416
ast::ExprKind::If(..)
417-
| ast::ExprKind::IfLet(..)
418417
| ast::ExprKind::ForLoop(..)
419418
| ast::ExprKind::Loop(..)
420419
| ast::ExprKind::While(..)
421-
| ast::ExprKind::WhileLet(..)
422420
| ast::ExprKind::Match(..) => {
423421
let multi_line = rewrite_cond(self.context, expr, shape)
424422
.map_or(false, |cond| cond.contains('\n'));

src/utils.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use syntax::ast::{
1010
use syntax::ptr;
1111
use syntax::source_map::{BytePos, Span, NO_EXPANSION};
1212
use syntax::symbol::{sym, Symbol};
13-
use syntax_pos::Mark;
13+
use syntax_pos::ExpnId;
1414
use unicode_width::UnicodeWidthStr;
1515

1616
use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
@@ -284,10 +284,9 @@ pub(crate) fn semicolon_for_expr(context: &RewriteContext<'_>, expr: &ast::Expr)
284284
pub(crate) fn semicolon_for_stmt(context: &RewriteContext<'_>, stmt: &ast::Stmt) -> bool {
285285
match stmt.node {
286286
ast::StmtKind::Semi(ref expr) => match expr.node {
287-
ast::ExprKind::While(..)
288-
| ast::ExprKind::WhileLet(..)
289-
| ast::ExprKind::Loop(..)
290-
| ast::ExprKind::ForLoop(..) => false,
287+
ast::ExprKind::While(..) | ast::ExprKind::Loop(..) | ast::ExprKind::ForLoop(..) => {
288+
false
289+
}
291290
ast::ExprKind::Break(..) | ast::ExprKind::Continue(..) | ast::ExprKind::Ret(..) => {
292291
context.config.trailing_semicolon()
293292
}
@@ -453,9 +452,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
453452
| ast::ExprKind::Array(..)
454453
| ast::ExprKind::Struct(..)
455454
| ast::ExprKind::While(..)
456-
| ast::ExprKind::WhileLet(..)
457455
| ast::ExprKind::If(..)
458-
| ast::ExprKind::IfLet(..)
459456
| ast::ExprKind::Block(..)
460457
| ast::ExprKind::Loop(..)
461458
| ast::ExprKind::ForLoop(..)
@@ -630,7 +627,7 @@ pub(crate) trait NodeIdExt {
630627

631628
impl NodeIdExt for NodeId {
632629
fn root() -> NodeId {
633-
NodeId::placeholder_from_mark(Mark::root())
630+
NodeId::placeholder_from_expn_id(ExpnId::root())
634631
}
635632
}
636633

0 commit comments

Comments
 (0)