Skip to content

Commit

Permalink
Update rustc-ap-* crates to 606.0.0 (rust-lang#3835)
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro authored Oct 5, 2019
1 parent fb01dc8 commit 383306e
Show file tree
Hide file tree
Showing 22 changed files with 202 additions and 265 deletions.
229 changes: 79 additions & 150 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ env_logger = "0.6"
getopts = "0.2"
derive-new = "0.5"
cargo_metadata = "0.8"
rustc-ap-rustc_target = "583.0.0"
rustc-ap-syntax = "583.0.0"
rustc-ap-syntax_pos = "583.0.0"
failure = "0.1.3"
bytecount = "0.6"
unicode-width = "0.1.5"
Expand All @@ -58,13 +55,24 @@ dirs = "2.0.1"
ignore = "0.4.6"
annotate-snippets = { version = "0.6", features = ["ansi_term"] }
structopt = "0.3"

rustfmt-config_proc_macro = { version = "0.2", path = "config_proc_macro" }

# A noop dependency that changes in the Rust repository, it's a bit of a hack.
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
# for more information.
rustc-workspace-hack = "1.0.0"

[dependencies.rustc_target]
package = "rustc-ap-rustc_target"
version = "606.0.0"

[dependencies.syntax]
package = "rustc-ap-syntax"
version = "606.0.0"

[dependencies.syntax_pos]
package = "rustc-ap-syntax_pos"
version = "606.0.0"

[dev-dependencies]
lazy_static = "1.0.0"
8 changes: 4 additions & 4 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod doc_comment;

/// Returns attributes on the given statement.
pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
match stmt.node {
match stmt.kind {
ast::StmtKind::Local(ref local) => &local.attrs,
ast::StmtKind::Item(ref item) => &item.attrs,
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => &expr.attrs,
Expand All @@ -29,7 +29,7 @@ pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
}

pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
match stmt.node {
match stmt.kind {
ast::StmtKind::Local(ref local) => local.span,
ast::StmtKind::Item(ref item) => item.span,
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => expr.span,
Expand Down Expand Up @@ -218,7 +218,7 @@ fn has_newlines_before_after_comment(comment: &str) -> (&str, &str) {

impl Rewrite for ast::MetaItem {
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
Some(match self.node {
Some(match self.kind {
ast::MetaItemKind::Word => {
rewrite_path(context, PathContext::Type, None, &self.path, shape)?
}
Expand Down Expand Up @@ -495,7 +495,7 @@ fn attr_prefix(attr: &ast::Attribute) -> &'static str {

pub(crate) trait MetaVisitor<'ast> {
fn visit_meta_item(&mut self, meta_item: &'ast ast::MetaItem) {
match meta_item.node {
match meta_item.kind {
ast::MetaItemKind::Word => self.visit_meta_word(meta_item),
ast::MetaItemKind::List(ref list) => self.visit_meta_list(meta_item, list),
ast::MetaItemKind::NameValue(ref lit) => self.visit_meta_name_value(meta_item, lit),
Expand Down
10 changes: 5 additions & 5 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl ChainItemKind {
}

fn is_tup_field_access(expr: &ast::Expr) -> bool {
match expr.node {
match expr.kind {
ast::ExprKind::Field(_, ref field) => {
field.name.to_string().chars().all(|c| c.is_digit(10))
}
Expand All @@ -144,7 +144,7 @@ impl ChainItemKind {
}

fn from_ast(context: &RewriteContext<'_>, expr: &ast::Expr) -> (ChainItemKind, Span) {
let (kind, span) = match expr.node {
let (kind, span) = match expr.kind {
ast::ExprKind::MethodCall(ref segment, ref expressions) => {
let types = if let Some(ref generic_args) = segment.args {
if let ast::GenericArgs::AngleBracketed(ref data) = **generic_args {
Expand Down Expand Up @@ -262,7 +262,7 @@ impl Chain {
let mut rev_children = vec![];
let mut sub_tries = 0;
for subexpr in &subexpr_list {
match subexpr.node {
match subexpr.kind {
ast::ExprKind::Try(_) => sub_tries += 1,
_ => {
rev_children.push(ChainItem::new(context, subexpr, sub_tries));
Expand Down Expand Up @@ -390,7 +390,7 @@ impl Chain {
// Returns the expression's subexpression, if it exists. When the subexpr
// is a try! macro, we'll convert it to shorthand when the option is set.
fn pop_expr_chain(expr: &ast::Expr, context: &RewriteContext<'_>) -> Option<ast::Expr> {
match expr.node {
match expr.kind {
ast::ExprKind::MethodCall(_, ref expressions) => {
Some(Self::convert_try(&expressions[0], context))
}
Expand All @@ -402,7 +402,7 @@ impl Chain {
}

fn convert_try(expr: &ast::Expr, context: &RewriteContext<'_>) -> ast::Expr {
match expr.node {
match expr.kind {
ast::ExprKind::Mac(ref mac) if context.config.use_try_shorthand() => {
if let Some(subexpr) = convert_try_mac(mac, context) {
subexpr
Expand Down
20 changes: 10 additions & 10 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub(crate) fn rewrite_closure(
// 1 = space between `|...|` and body.
let body_shape = shape.offset_left(extra_offset)?;

if let ast::ExprKind::Block(ref block, _) = body.node {
if let ast::ExprKind::Block(ref block, _) = body.kind {
// The body of the closure is an empty block.
if block.stmts.is_empty() && !block_contains_comment(block, context.source_map) {
return body
Expand Down Expand Up @@ -89,7 +89,7 @@ fn get_inner_expr<'a>(
prefix: &str,
context: &RewriteContext<'_>,
) -> &'a ast::Expr {
if let ast::ExprKind::Block(ref block, _) = expr.node {
if let ast::ExprKind::Block(ref block, _) = expr.kind {
if !needs_block(block, prefix, context) {
// block.stmts.len() == 1
if let Some(expr) = stmt_expr(&block.stmts[0]) {
Expand All @@ -110,7 +110,7 @@ fn needs_block(block: &ast::Block, prefix: &str, context: &RewriteContext<'_>) -
}

fn veto_block(e: &ast::Expr) -> bool {
match e.node {
match e.kind {
ast::ExprKind::Call(..)
| ast::ExprKind::Binary(..)
| ast::ExprKind::Cast(..)
Expand Down Expand Up @@ -141,7 +141,7 @@ fn rewrite_closure_with_block(
let block = ast::Block {
stmts: vec![ast::Stmt {
id: ast::NodeId::root(),
node: ast::StmtKind::Expr(ptr::P(body.clone())),
kind: ast::StmtKind::Expr(ptr::P(body.clone())),
span: body.span,
}],
id: ast::NodeId::root(),
Expand All @@ -161,7 +161,7 @@ fn rewrite_closure_expr(
shape: Shape,
) -> Option<String> {
fn allow_multi_line(expr: &ast::Expr) -> bool {
match expr.node {
match expr.kind {
ast::ExprKind::Match(..)
| ast::ExprKind::Block(..)
| ast::ExprKind::TryBlock(..)
Expand Down Expand Up @@ -291,9 +291,9 @@ pub(crate) fn rewrite_last_closure(
shape: Shape,
) -> Option<String> {
if let ast::ExprKind::Closure(capture, ref is_async, movability, ref fn_decl, ref body, _) =
expr.node
expr.kind
{
let body = match body.node {
let body = match body.kind {
ast::ExprKind::Block(ref block, _)
if !is_unsafe_block(block)
&& !context.inside_macro()
Expand Down Expand Up @@ -353,7 +353,7 @@ pub(crate) fn rewrite_last_closure(
pub(crate) fn args_have_many_closure(args: &[OverflowableItem<'_>]) -> bool {
args.iter()
.filter_map(OverflowableItem::to_expr)
.filter(|expr| match expr.node {
.filter(|expr| match expr.kind {
ast::ExprKind::Closure(..) => true,
_ => false,
})
Expand All @@ -371,7 +371,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 {
match expr.kind {
ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true,
ast::ExprKind::Loop(..) if version == Version::Two => true,
ast::ExprKind::AddrOf(_, ref expr)
Expand All @@ -392,7 +392,7 @@ fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
/// isn't parsed as (if true {...} else {...} | x) | 5
// From https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/classify.rs.
fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
match e.node {
match e.kind {
ast::ExprKind::If(..)
| ast::ExprKind::Match(..)
| ast::ExprKind::Block(..)
Expand Down
32 changes: 16 additions & 16 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) fn format_expr(
shape
};

let expr_rw = match expr.node {
let expr_rw = match expr.kind {
ast::ExprKind::Array(ref expr_vec) => rewrite_array(
"",
expr_vec.iter(),
Expand Down Expand Up @@ -250,8 +250,8 @@ pub(crate) fn format_expr(
};

fn needs_space_before_range(context: &RewriteContext<'_>, lhs: &ast::Expr) -> bool {
match lhs.node {
ast::ExprKind::Lit(ref lit) => match lit.node {
match lhs.kind {
ast::ExprKind::Lit(ref lit) => match lit.kind {
ast::LitKind::FloatUnsuffixed(..) => {
context.snippet(lit.span).ends_with('.')
}
Expand All @@ -262,7 +262,7 @@ pub(crate) fn format_expr(
}

fn needs_space_after_range(rhs: &ast::Expr) -> bool {
match rhs.node {
match rhs.kind {
// Don't format `.. ..` into `....`, which is invalid.
//
// This check is unnecessary for `lhs`, because a range
Expand Down Expand Up @@ -575,7 +575,7 @@ pub(crate) fn rewrite_cond(
expr: &ast::Expr,
shape: Shape,
) -> Option<String> {
match expr.node {
match expr.kind {
ast::ExprKind::Match(ref cond, _) => {
// `match `cond` {`
let cond_shape = match context.config.indent_style() {
Expand Down Expand Up @@ -612,15 +612,15 @@ struct ControlFlow<'a> {
}

fn extract_pats_and_cond(expr: &ast::Expr) -> (Option<&ast::Pat>, &ast::Expr) {
match expr.node {
match expr.kind {
ast::ExprKind::Let(ref pat, ref cond) => (Some(pat), cond),
_ => (None, expr),
}
}

// FIXME: Refactor this.
fn to_control_flow(expr: &ast::Expr, expr_type: ExprType) -> Option<ControlFlow<'_>> {
match expr.node {
match expr.kind {
ast::ExprKind::If(ref cond, ref if_block, ref else_block) => {
let (pat, cond) = extract_pats_and_cond(cond);
Some(ControlFlow::new_if(
Expand Down Expand Up @@ -748,7 +748,7 @@ impl<'a> ControlFlow<'a> {
let else_block = self.else_block?;
let fixed_cost = self.keyword.len() + " { } else { }".len();

if let ast::ExprKind::Block(ref else_node, _) = else_block.node {
if let ast::ExprKind::Block(ref else_node, _) = else_block.kind {
if !is_simple_block(self.block, None, context.source_map)
|| !is_simple_block(else_node, None, context.source_map)
|| pat_expr_str.contains('\n')
Expand Down Expand Up @@ -1014,7 +1014,7 @@ impl<'a> Rewrite for ControlFlow<'a> {
if let Some(else_block) = self.else_block {
let shape = Shape::indented(shape.indent, context.config);
let mut last_in_chain = false;
let rewrite = match else_block.node {
let rewrite = match else_block.kind {
// If the else expression is another if-else expression, prevent it
// from being formatted on a single line.
// Note how we're passing the original shape, as the
Expand Down Expand Up @@ -1149,7 +1149,7 @@ pub(crate) fn is_empty_block(
}

pub(crate) fn stmt_is_expr(stmt: &ast::Stmt) -> bool {
match stmt.node {
match stmt.kind {
ast::StmtKind::Expr(..) => true,
_ => false,
}
Expand All @@ -1168,7 +1168,7 @@ pub(crate) fn rewrite_literal(
l: &ast::Lit,
shape: Shape,
) -> Option<String> {
match l.node {
match l.kind {
ast::LitKind::Str(_, ast::StrStyle::Cooked) => rewrite_string_lit(context, l.span, shape),
_ => wrap_str(
context.snippet(l.span).to_owned(),
Expand Down Expand Up @@ -1253,7 +1253,7 @@ pub(crate) fn rewrite_call(
}

pub(crate) fn is_simple_expr(expr: &ast::Expr) -> bool {
match expr.node {
match expr.kind {
ast::ExprKind::Lit(..) => true,
ast::ExprKind::Path(ref qself, ref path) => qself.is_none() && path.segments.len() <= 1,
ast::ExprKind::AddrOf(_, ref expr)
Expand All @@ -1279,7 +1279,7 @@ pub(crate) fn can_be_overflowed_expr(
expr: &ast::Expr,
args_len: usize,
) -> bool {
match expr.node {
match expr.kind {
_ if !expr.attrs.is_empty() => false,
ast::ExprKind::Match(..) => {
(context.use_block_indent() && args_len == 1)
Expand Down Expand Up @@ -1324,7 +1324,7 @@ pub(crate) fn can_be_overflowed_expr(
}

pub(crate) fn is_nested_call(expr: &ast::Expr) -> bool {
match expr.node {
match expr.kind {
ast::ExprKind::Call(..) | ast::ExprKind::Mac(..) => true,
ast::ExprKind::AddrOf(_, ref expr)
| ast::ExprKind::Box(ref expr)
Expand Down Expand Up @@ -1380,7 +1380,7 @@ fn rewrite_paren(
post_comment = rewrite_missing_comment(post_span, shape, context)?;

// Remove nested parens if there are no comments.
if let ast::ExprKind::Paren(ref subsubexpr) = subexpr.node {
if let ast::ExprKind::Paren(ref subsubexpr) = subexpr.kind {
if remove_nested_parens && pre_comment.is_empty() && post_comment.is_empty() {
span = subexpr.span;
subexpr = subsubexpr;
Expand Down Expand Up @@ -1985,7 +1985,7 @@ fn rewrite_expr_addrof(
}

pub(crate) fn is_method_call(expr: &ast::Expr) -> bool {
match expr.node {
match expr.kind {
ast::ExprKind::MethodCall(..) => true,
ast::ExprKind::AddrOf(_, ref expr)
| ast::ExprKind::Box(ref expr)
Expand Down
18 changes: 9 additions & 9 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::time::{Duration, Instant};

use syntax::ast;
use syntax::errors::emitter::{ColorConfig, Emitter};
use syntax::errors::{DiagnosticBuilder, Handler};
use syntax::errors::{Diagnostic, DiagnosticBuilder, Handler};
use syntax::parse::{self, ParseSess};
use syntax::source_map::{FilePathMapping, SourceMap, Span, DUMMY_SP};

Expand Down Expand Up @@ -640,12 +640,6 @@ fn parse_crate(
.map(|mut parser| {
parser.recurse_into_file_modules = false;
parser
})
.map_err(|diags| {
diags
.into_iter()
.map(|d| DiagnosticBuilder::new_diagnostic(&parse_session.span_diagnostic, d))
.collect::<Vec<_>>()
}),
};

Expand All @@ -659,7 +653,13 @@ fn parse_crate(
let mut parser = AssertUnwindSafe(parser);
catch_unwind(move || parser.0.parse_crate_mod().map_err(|d| vec![d]))
}
Err(db) => Ok(Err(db)),
Err(diagnostics) => {
for diagnostic in diagnostics {
parse_session.span_diagnostic.emit_diagnostic(&diagnostic);
}
report.add_parsing_error();
return Err(ErrorKind::ParseError);
}
};

match result {
Expand Down Expand Up @@ -687,7 +687,7 @@ fn parse_crate(
struct SilentEmitter;

impl Emitter for SilentEmitter {
fn emit_diagnostic(&mut self, _db: &DiagnosticBuilder<'_>) {}
fn emit_diagnostic(&mut self, _db: &Diagnostic) {}
}

fn silent_emitter() -> Box<SilentEmitter> {
Expand Down
2 changes: 1 addition & 1 deletion src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl UseTree {
context: &RewriteContext<'_>,
item: &ast::Item,
) -> Option<UseTree> {
match item.node {
match item.kind {
ast::ItemKind::Use(ref use_tree) => Some(
UseTree::from_ast(
context,
Expand Down
Loading

0 comments on commit 383306e

Please sign in to comment.