Skip to content

Update rustc-ap-* to 174.0.0 #2806

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
Jun 25, 2018
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
92 changes: 46 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ env_logger = "0.5"
getopts = "0.2"
derive-new = "0.5"
cargo_metadata = "0.5.1"
rustc-ap-rustc_target = "164.0.0"
rustc-ap-syntax = "164.0.0"
rustc-ap-rustc_target = "174.0.0"
rustc-ap-syntax = "174.0.0"
failure = "0.1.1"

[dev-dependencies]
Expand Down
9 changes: 5 additions & 4 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ use expr::rewrite_call;
use macros::convert_try_mac;
use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
use spanned::Spanned;
use utils::{
first_line_width, last_line_extendable, last_line_width, mk_sp, trimmed_last_line_width,
wrap_str,
Expand Down Expand Up @@ -436,9 +437,9 @@ fn rewrite_chain_subexpr(

match expr.node {
ast::ExprKind::MethodCall(ref segment, ref expressions) => {
let types = match segment.parameters {
let types = match segment.args {
Some(ref params) => match **params {
ast::PathParameters::AngleBracketed(ref data) => &data.types[..],
ast::GenericArgs::AngleBracketed(ref data) => &data.args[..],
_ => &[],
},
_ => &[],
Expand Down Expand Up @@ -484,7 +485,7 @@ fn is_try(expr: &ast::Expr) -> bool {

fn rewrite_method_call(
method_name: ast::Ident,
types: &[ptr::P<ast::Ty>],
types: &[ast::GenericArg],
args: &[ptr::P<ast::Expr>],
span: Span,
context: &RewriteContext,
Expand All @@ -500,7 +501,7 @@ fn rewrite_method_call(

let type_str = format!("::<{}>", type_list.join(", "));

(types.last().unwrap().span.hi(), type_str)
(types.last().unwrap().span().hi(), type_str)
};

let callee_str = format!(".{}{}", method_name, type_str);
Expand Down
29 changes: 22 additions & 7 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,8 +2014,8 @@ fn rewrite_assignment(
pub enum RhsTactics {
/// Use heuristics.
Default,
/// Put the rhs on the next line if it uses multiple line.
ForceNextLine,
/// Put the rhs on the next line if it uses multiple line, without extra indentation.
ForceNextLineWithoutIndent,
}

// The left hand side must contain everything up to, and including, the
Expand Down Expand Up @@ -2072,11 +2072,12 @@ fn choose_rhs<R: Rewrite>(
_ => {
// Expression did not fit on the same line as the identifier.
// Try splitting the line and see if that works better.
let new_shape =
Shape::indented(shape.indent.block_indent(context.config), context.config)
.sub_width(shape.rhs_overhead(context.config))?;
let new_shape = shape_from_rhs_tactic(context, shape, rhs_tactics)?;
let new_rhs = expr.rewrite(context, new_shape);
let new_indent_str = &new_shape.indent.to_string_with_newline(context.config);
let new_indent_str = &shape
.indent
.block_indent(context.config)
.to_string_with_newline(context.config);

match (orig_rhs, new_rhs) {
(Some(ref orig_rhs), Some(ref new_rhs))
Expand All @@ -2098,8 +2099,22 @@ fn choose_rhs<R: Rewrite>(
}
}

fn shape_from_rhs_tactic(
context: &RewriteContext,
shape: Shape,
rhs_tactic: RhsTactics,
) -> Option<Shape> {
match rhs_tactic {
RhsTactics::ForceNextLineWithoutIndent => Some(shape.with_max_width(context.config)),
RhsTactics::Default => {
Shape::indented(shape.indent.block_indent(context.config), context.config)
.sub_width(shape.rhs_overhead(context.config))
}
}
}

pub fn prefer_next_line(orig_rhs: &str, next_line_rhs: &str, rhs_tactics: RhsTactics) -> bool {
rhs_tactics == RhsTactics::ForceNextLine
rhs_tactics == RhsTactics::ForceNextLineWithoutIndent
|| !next_line_rhs.contains('\n')
|| count_newlines(orig_rhs) > count_newlines(next_line_rhs) + 1
}
Expand Down
2 changes: 1 addition & 1 deletion src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl UseTree {
.collect(),
));
}
UseTreeKind::Simple(ref rename) => {
UseTreeKind::Simple(ref rename, ..) => {
let mut name = (*path_to_imported_ident(&a.prefix).name.as_str()).to_owned();
let alias = rename.and_then(|ident| {
if ident == path_to_imported_ident(&a.prefix) {
Expand Down
Loading