Skip to content

Update rustfmt for ast::ExprKind::MethodCall changes #1774

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 1 commit into from
Jul 10, 2017
Merged
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
28 changes: 23 additions & 5 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,22 @@ fn rewrite_method_call_with_overflow(
context: &RewriteContext,
shape: Shape,
) -> bool {
if let &ast::ExprKind::MethodCall(ref method_name, ref types, ref expressions) = expr_kind {
if let &ast::ExprKind::MethodCall(ref segment, ref expressions) = expr_kind {
let shape = match shape.shrink_left(almost_total) {
Some(b) => b,
None => return false,
};
let types = match segment.parameters {
Some(ref params) => {
match **params {
ast::PathParameters::AngleBracketed(ref data) => &data.types[..],
_ => &[],
}
}
_ => &[],
};
let mut last_rewrite = rewrite_method_call(
method_name.node,
segment.identifier,
types,
expressions,
total_span,
Expand All @@ -466,7 +475,7 @@ fn rewrite_method_call_with_overflow(
// 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 {
ast::ExprKind::MethodCall(_, _, ref expressions) => {
ast::ExprKind::MethodCall(_, ref expressions) => {
Some(convert_try(&expressions[0], context))
}
ast::ExprKind::TupField(ref subexpr, _) |
Expand Down Expand Up @@ -504,8 +513,17 @@ fn rewrite_chain_subexpr(
};

match expr.node {
ast::ExprKind::MethodCall(ref method_name, ref types, ref expressions) => {
rewrite_method_call(method_name.node, types, expressions, span, context, shape)
ast::ExprKind::MethodCall(ref segment, ref expressions) => {
let types = match segment.parameters {
Some(ref params) => {
match **params {
ast::PathParameters::AngleBracketed(ref data) => &data.types[..],
_ => &[],
}
}
_ => &[],
};
rewrite_method_call(segment.identifier, types, expressions, span, context, shape)
}
ast::ExprKind::Field(_, ref field) => rewrite_element(format!(".{}", field.node)),
ast::ExprKind::TupField(ref expr, ref field) => {
Expand Down