Skip to content

Update rustc-ap-* crates to 541.0.0 #3707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
561 changes: 295 additions & 266 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
unicode-segmentation = "1.0.0"
regex = "1.0"
term = "0.5"
term = "0.6"
diff = "0.1"
log = "0.4"
env_logger = "0.6"
getopts = "0.2"
derive-new = "0.5"
cargo_metadata = "0.8"
rustc-ap-rustc_target = "491.0.0"
rustc-ap-syntax = "491.0.0"
rustc-ap-syntax_pos = "491.0.0"
rustc-ap-rustc_target = "541.0.0"
rustc-ap-syntax = "541.0.0"
rustc-ap-syntax_pos = "541.0.0"
failure = "0.1.3"
bytecount = "0.5"
unicode-width = "0.1.5"
unicode_categories = "0.1.1"
dirs = "2.0.1"
ignore = "0.4.6"
annotate-snippets = { version = "0.5.0", features = ["ansi_term"] }
annotate-snippets = { version = "0.6", features = ["ansi_term"] }
structopt = "0.2.18"

rustfmt-config_proc_macro = { version = "0.1", path = "config_proc_macro" }
Expand Down
8 changes: 1 addition & 7 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,7 @@ fn is_block_closure_forced(context: &RewriteContext<'_>, expr: &ast::Expr) -> bo

fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
match expr.node {
ast::ExprKind::If(..)
| ast::ExprKind::IfLet(..)
| ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..)
| ast::ExprKind::ForLoop(..) => true,
ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true,
ast::ExprKind::Loop(..) if version == Version::Two => true,
ast::ExprKind::AddrOf(_, ref expr)
| ast::ExprKind::Box(ref expr)
Expand All @@ -398,11 +394,9 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
match e.node {
ast::ExprKind::If(..)
| ast::ExprKind::IfLet(..)
| ast::ExprKind::Match(..)
| ast::ExprKind::Block(..)
| ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..)
| ast::ExprKind::Loop(..)
| ast::ExprKind::ForLoop(..)
| ast::ExprKind::TryBlock(..) => false,
Expand Down
60 changes: 20 additions & 40 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ pub(crate) fn format_expr(
ast::ExprKind::Tup(ref items) => {
rewrite_tuple(context, items.iter(), expr.span, shape, items.len() == 1)
}
ast::ExprKind::Let(..) => None,
ast::ExprKind::If(..)
| ast::ExprKind::IfLet(..)
| ast::ExprKind::ForLoop(..)
| ast::ExprKind::Loop(..)
| ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..) => to_control_flow(expr, expr_type)
| ast::ExprKind::While(..) => to_control_flow(expr, expr_type)
.and_then(|control_flow| control_flow.rewrite(context, shape)),
ast::ExprKind::Block(ref block, opt_label) => {
match expr_type {
Expand Down Expand Up @@ -610,21 +609,21 @@ struct ControlFlow<'a> {
span: Span,
}

fn extract_pats_and_cond(expr: &ast::Expr) -> (Vec<&ast::Pat>, &ast::Expr) {
match expr.node {
ast::ExprKind::Let(ref pats, ref cond) => (ptr_vec_to_ref_vec(pats), cond),
_ => (vec![], expr),
}
}

// FIXME: Refactor this.
fn to_control_flow(expr: &ast::Expr, expr_type: ExprType) -> Option<ControlFlow<'_>> {
match expr.node {
ast::ExprKind::If(ref cond, ref if_block, ref else_block) => Some(ControlFlow::new_if(
cond,
vec![],
if_block,
else_block.as_ref().map(|e| &**e),
expr_type == ExprType::SubExpression,
false,
expr.span,
)),
ast::ExprKind::IfLet(ref pat, ref cond, ref if_block, ref else_block) => {
ast::ExprKind::If(ref cond, ref if_block, ref else_block) => {
let (pats, cond) = extract_pats_and_cond(cond);
Some(ControlFlow::new_if(
cond,
ptr_vec_to_ref_vec(pat),
pats,
if_block,
else_block.as_ref().map(|e| &**e),
expr_type == ExprType::SubExpression,
Expand All @@ -638,16 +637,10 @@ fn to_control_flow(expr: &ast::Expr, expr_type: ExprType) -> Option<ControlFlow<
ast::ExprKind::Loop(ref block, label) => {
Some(ControlFlow::new_loop(block, label, expr.span))
}
ast::ExprKind::While(ref cond, ref block, label) => Some(ControlFlow::new_while(
vec![],
cond,
block,
label,
expr.span,
)),
ast::ExprKind::WhileLet(ref pat, ref cond, ref block, label) => Some(
ControlFlow::new_while(ptr_vec_to_ref_vec(pat), cond, block, label, expr.span),
),
ast::ExprKind::While(ref cond, ref block, label) => {
let (pats, cond) = extract_pats_and_cond(cond);
Some(ControlFlow::new_while(pats, cond, block, label, expr.span))
}
_ => None,
}
}
Expand Down Expand Up @@ -1020,22 +1013,11 @@ impl<'a> Rewrite for ControlFlow<'a> {
// from being formatted on a single line.
// Note how we're passing the original shape, as the
// cost of "else" should not cascade.
ast::ExprKind::IfLet(ref pat, ref cond, ref if_block, ref next_else_block) => {
ControlFlow::new_if(
cond,
ptr_vec_to_ref_vec(pat),
if_block,
next_else_block.as_ref().map(|e| &**e),
false,
true,
mk_sp(else_block.span.lo(), self.span.hi()),
)
.rewrite(context, shape)
}
ast::ExprKind::If(ref cond, ref if_block, ref next_else_block) => {
let (pats, cond) = extract_pats_and_cond(cond);
ControlFlow::new_if(
cond,
vec![],
pats,
if_block,
next_else_block.as_ref().map(|e| &**e),
false,
Expand Down Expand Up @@ -1332,11 +1314,9 @@ pub(crate) fn can_be_overflowed_expr(
|| context.config.overflow_delimited_expr()
}
ast::ExprKind::If(..)
| ast::ExprKind::IfLet(..)
| ast::ExprKind::ForLoop(..)
| ast::ExprKind::Loop(..)
| ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..) => {
| ast::ExprKind::While(..) => {
context.config.combine_control_expr() && context.use_block_indent() && args_len == 1
}

Expand Down
2 changes: 1 addition & 1 deletion src/format_report_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct FormatReportFormatter<'a> {

impl<'a> Display for FormatReportFormatter<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let formatter = DisplayListFormatter::new(self.enable_colors);
let formatter = DisplayListFormatter::new(self.enable_colors, false);
let errors_by_file = &self.report.internal.borrow().0;

for (file, errors) in errors_by_file {
Expand Down
10 changes: 5 additions & 5 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ impl MacroArgParser {
break;
}
TokenTree::Token(ref t) => {
buffer.push_str(&pprust::token_to_string(&t.kind));
buffer.push_str(&pprust::token_to_string(&t));
hi = t.span.hi();
}
_ => return None,
Expand Down Expand Up @@ -945,13 +945,13 @@ impl MacroArgParser {
self.lo = t.span.lo();
self.start_tok = t.clone();
} else {
let needs_space = match next_space(&self.last_tok) {
let needs_space = match next_space(&self.last_tok.kind) {
SpaceState::Ident => ident_like(t),
SpaceState::Punctuation => !ident_like(t),
SpaceState::Always => true,
SpaceState::Never => false,
};
if force_space_before(t) || needs_space {
if force_space_before(&t.kind) || needs_space {
self.buf.push(' ');
}
}
Expand All @@ -974,7 +974,7 @@ impl MacroArgParser {
}
}

if force_space_before(&self.start_tok) {
if force_space_before(&self.start_tok.kind) {
return true;
}

Expand Down Expand Up @@ -1013,7 +1013,7 @@ impl MacroArgParser {
TokenTree::Token(ref t) => self.update_buffer(t),
TokenTree::Delimited(delimited_span, delimited, ref tts) => {
if !self.buf.is_empty() {
if next_space(&self.last_tok) == SpaceState::Always {
if next_space(&self.last_tok.kind) == SpaceState::Always {
self.add_separator();
} else {
self.add_other();
Expand Down
16 changes: 3 additions & 13 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,18 +488,10 @@ fn rewrite_match_body(
}
}

impl Rewrite for ast::Guard {
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
match self {
ast::Guard::If(ref expr) => expr.rewrite(context, shape),
}
}
}

// The `if ...` guard on a match arm.
fn rewrite_guard(
context: &RewriteContext<'_>,
guard: &Option<ast::Guard>,
guard: &Option<ptr::P<ast::Expr>>,
shape: Shape,
// The amount of space used up on this line for the pattern in
// the arm (excludes offset).
Expand Down Expand Up @@ -561,12 +553,10 @@ fn can_flatten_block_around_this(body: &ast::Expr) -> bool {
match body.node {
// We do not allow `if` to stay on the same line, since we could easily mistake
// `pat => if cond { ... }` and `pat if cond => { ... }`.
ast::ExprKind::If(..) | ast::ExprKind::IfLet(..) => false,
ast::ExprKind::If(..) => false,
// We do not allow collapsing a block around expression with condition
// to avoid it being cluttered with match arm.
ast::ExprKind::ForLoop(..) | ast::ExprKind::While(..) | ast::ExprKind::WhileLet(..) => {
false
}
ast::ExprKind::ForLoop(..) | ast::ExprKind::While(..) => false,
ast::ExprKind::Loop(..)
| ast::ExprKind::Match(..)
| ast::ExprKind::Block(..)
Expand Down
2 changes: 0 additions & 2 deletions src/overflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,9 @@ impl<'a> Context<'a> {
// When overflowing the expressions which consists of a control flow
// expression, avoid condition to use multi line.
ast::ExprKind::If(..)
| ast::ExprKind::IfLet(..)
| ast::ExprKind::ForLoop(..)
| ast::ExprKind::Loop(..)
| ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..)
| ast::ExprKind::Match(..) => {
let multi_line = rewrite_cond(self.context, expr, shape)
.map_or(false, |cond| cond.contains('\n'));
Expand Down
13 changes: 5 additions & 8 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use syntax::ast::{
use syntax::ptr;
use syntax::source_map::{BytePos, Span, NO_EXPANSION};
use syntax::symbol::{sym, Symbol};
use syntax_pos::Mark;
use syntax_pos::ExpnId;
use unicode_width::UnicodeWidthStr;

use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
Expand Down Expand Up @@ -284,10 +284,9 @@ pub(crate) fn semicolon_for_expr(context: &RewriteContext<'_>, expr: &ast::Expr)
pub(crate) fn semicolon_for_stmt(context: &RewriteContext<'_>, stmt: &ast::Stmt) -> bool {
match stmt.node {
ast::StmtKind::Semi(ref expr) => match expr.node {
ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..)
| ast::ExprKind::Loop(..)
| ast::ExprKind::ForLoop(..) => false,
ast::ExprKind::While(..) | ast::ExprKind::Loop(..) | ast::ExprKind::ForLoop(..) => {
false
}
ast::ExprKind::Break(..) | ast::ExprKind::Continue(..) | ast::ExprKind::Ret(..) => {
context.config.trailing_semicolon()
}
Expand Down Expand Up @@ -453,9 +452,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
| ast::ExprKind::Array(..)
| ast::ExprKind::Struct(..)
| ast::ExprKind::While(..)
| ast::ExprKind::WhileLet(..)
| ast::ExprKind::If(..)
| ast::ExprKind::IfLet(..)
| ast::ExprKind::Block(..)
| ast::ExprKind::Loop(..)
| ast::ExprKind::ForLoop(..)
Expand Down Expand Up @@ -630,7 +627,7 @@ pub(crate) trait NodeIdExt {

impl NodeIdExt for NodeId {
fn root() -> NodeId {
NodeId::placeholder_from_mark(Mark::root())
NodeId::placeholder_from_expn_id(ExpnId::root())
}
}

Expand Down
3 changes: 0 additions & 3 deletions tests/source/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ itemmacro!(really, long.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

itemmacro!{this, is.brace().formatted()}

peg_file! modname ("mygrammarfile.rustpeg");

fn main() {
foo! ( );

Expand Down Expand Up @@ -474,7 +472,6 @@ pub fn fold_abi<V: Fold + ?Sized>(_visitor: &mut V, _i: Abi) -> Abi {

// #3463
x ! {()}
x ! y {()}

// #3583
foo!(|x = y|);
6 changes: 0 additions & 6 deletions tests/target/issue-3439.rs

This file was deleted.

3 changes: 0 additions & 3 deletions tests/target/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ itemmacro!(

itemmacro! {this, is.brace().formatted()}

peg_file! modname("mygrammarfile.rustpeg");

fn main() {
foo!();

Expand Down Expand Up @@ -1051,7 +1049,6 @@ pub fn fold_abi<V: Fold + ?Sized>(_visitor: &mut V, _i: Abi) -> Abi {

// #3463
x! {()}
x! y {()}

// #3583
foo!(|x = y|);