From d4c8a176657fcbeb038f86c470b808145bb62a29 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 7 Jul 2017 15:52:23 +0300 Subject: [PATCH] Update rustfmt for ast::ExprKind::MethodCall changes --- src/chains.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/chains.rs b/src/chains.rs index fb26fb2ff7d..c4dbacb0421 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -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, @@ -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 { match expr.node { - ast::ExprKind::MethodCall(_, _, ref expressions) => { + ast::ExprKind::MethodCall(_, ref expressions) => { Some(convert_try(&expressions[0], context)) } ast::ExprKind::TupField(ref subexpr, _) | @@ -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) => { -- 2.44.0