Skip to content

Commit 0877517

Browse files
authored
Merge pull request #2806 from topecongiro/rustc-ap-syntax
Update rustc-ap-* to 174.0.0
2 parents 87edd75 + fa19788 commit 0877517

File tree

11 files changed

+175
-161
lines changed

11 files changed

+175
-161
lines changed

Cargo.lock

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

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ env_logger = "0.5"
4747
getopts = "0.2"
4848
derive-new = "0.5"
4949
cargo_metadata = "0.5.1"
50-
rustc-ap-rustc_target = "164.0.0"
51-
rustc-ap-syntax = "164.0.0"
50+
rustc-ap-rustc_target = "174.0.0"
51+
rustc-ap-syntax = "174.0.0"
5252
failure = "0.1.1"
5353

5454
[dev-dependencies]

src/chains.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ use expr::rewrite_call;
7070
use macros::convert_try_mac;
7171
use rewrite::{Rewrite, RewriteContext};
7272
use shape::Shape;
73+
use spanned::Spanned;
7374
use utils::{
7475
first_line_width, last_line_extendable, last_line_width, mk_sp, trimmed_last_line_width,
7576
wrap_str,
@@ -436,9 +437,9 @@ fn rewrite_chain_subexpr(
436437

437438
match expr.node {
438439
ast::ExprKind::MethodCall(ref segment, ref expressions) => {
439-
let types = match segment.parameters {
440+
let types = match segment.args {
440441
Some(ref params) => match **params {
441-
ast::PathParameters::AngleBracketed(ref data) => &data.types[..],
442+
ast::GenericArgs::AngleBracketed(ref data) => &data.args[..],
442443
_ => &[],
443444
},
444445
_ => &[],
@@ -484,7 +485,7 @@ fn is_try(expr: &ast::Expr) -> bool {
484485

485486
fn rewrite_method_call(
486487
method_name: ast::Ident,
487-
types: &[ptr::P<ast::Ty>],
488+
types: &[ast::GenericArg],
488489
args: &[ptr::P<ast::Expr>],
489490
span: Span,
490491
context: &RewriteContext,
@@ -500,7 +501,7 @@ fn rewrite_method_call(
500501

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

503-
(types.last().unwrap().span.hi(), type_str)
504+
(types.last().unwrap().span().hi(), type_str)
504505
};
505506

506507
let callee_str = format!(".{}{}", method_name, type_str);

src/expr.rs

+22-7
Original file line numberDiff line numberDiff line change
@@ -2014,8 +2014,8 @@ fn rewrite_assignment(
20142014
pub enum RhsTactics {
20152015
/// Use heuristics.
20162016
Default,
2017-
/// Put the rhs on the next line if it uses multiple line.
2018-
ForceNextLine,
2017+
/// Put the rhs on the next line if it uses multiple line, without extra indentation.
2018+
ForceNextLineWithoutIndent,
20192019
}
20202020

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

20812082
match (orig_rhs, new_rhs) {
20822083
(Some(ref orig_rhs), Some(ref new_rhs))
@@ -2098,8 +2099,22 @@ fn choose_rhs<R: Rewrite>(
20982099
}
20992100
}
21002101

2102+
fn shape_from_rhs_tactic(
2103+
context: &RewriteContext,
2104+
shape: Shape,
2105+
rhs_tactic: RhsTactics,
2106+
) -> Option<Shape> {
2107+
match rhs_tactic {
2108+
RhsTactics::ForceNextLineWithoutIndent => Some(shape.with_max_width(context.config)),
2109+
RhsTactics::Default => {
2110+
Shape::indented(shape.indent.block_indent(context.config), context.config)
2111+
.sub_width(shape.rhs_overhead(context.config))
2112+
}
2113+
}
2114+
}
2115+
21012116
pub fn prefer_next_line(orig_rhs: &str, next_line_rhs: &str, rhs_tactics: RhsTactics) -> bool {
2102-
rhs_tactics == RhsTactics::ForceNextLine
2117+
rhs_tactics == RhsTactics::ForceNextLineWithoutIndent
21032118
|| !next_line_rhs.contains('\n')
21042119
|| count_newlines(orig_rhs) > count_newlines(next_line_rhs) + 1
21052120
}

src/imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl UseTree {
346346
.collect(),
347347
));
348348
}
349-
UseTreeKind::Simple(ref rename) => {
349+
UseTreeKind::Simple(ref rename, ..) => {
350350
let mut name = (*path_to_imported_ident(&a.prefix).name.as_str()).to_owned();
351351
let alias = rename.and_then(|ident| {
352352
if ident == path_to_imported_ident(&a.prefix) {

0 commit comments

Comments
 (0)