From 832c0830ec3d6be0f406cc76611975a1cb8bd8bc Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 28 Aug 2019 10:41:06 +0200 Subject: [PATCH] Also return the method spans in utils::method_calls --- clippy_lints/src/utils/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 8fb458996..9d88e020f 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -339,25 +339,27 @@ pub fn resolve_node(cx: &LateContext<'_, '_>, qpath: &QPath, id: HirId) -> Res { /// Returns the method names and argument list of nested method call expressions that make up /// `expr`. -pub fn method_calls(expr: &Expr, max_depth: usize) -> (Vec, Vec<&[Expr]>) { +pub fn method_calls(expr: &Expr, max_depth: usize) -> (Vec, Vec<&[Expr]>, Vec) { let mut method_names = Vec::with_capacity(max_depth); let mut arg_lists = Vec::with_capacity(max_depth); + let mut spans = Vec::with_capacity(max_depth); let mut current = expr; for _ in 0..max_depth { - if let ExprKind::MethodCall(path, _, args) = ¤t.node { + if let ExprKind::MethodCall(path, span, args) = ¤t.node { if args.iter().any(|e| e.span.from_expansion()) { break; } method_names.push(path.ident.name); arg_lists.push(&**args); + spans.push(*span); current = &args[0]; } else { break; } } - (method_names, arg_lists) + (method_names, arg_lists, spans) } /// Matches an `Expr` against a chain of methods, and return the matched `Expr`s.