]> git.lizzy.rs Git - rust.git/commitdiff
Update rustfmt for ast::ExprKind::MethodCall changes
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Fri, 7 Jul 2017 12:52:23 +0000 (15:52 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Fri, 7 Jul 2017 12:52:23 +0000 (15:52 +0300)
src/chains.rs

index fb26fb2ff7d80a6e28621a9fd0571a35b4150df0..c4dbacb04213ea67edd1bc3d5893cd95b0f292db 100644 (file)
@@ -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<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, _) |
@@ -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) => {