Skip to content

Commit 832c083

Browse files
committed
Also return the method spans in utils::method_calls
1 parent 945d4cf commit 832c083

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

clippy_lints/src/utils/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,25 +339,27 @@ pub fn resolve_node(cx: &LateContext<'_, '_>, qpath: &QPath, id: HirId) -> Res {
339339

340340
/// Returns the method names and argument list of nested method call expressions that make up
341341
/// `expr`.
342-
pub fn method_calls(expr: &Expr, max_depth: usize) -> (Vec<Symbol>, Vec<&[Expr]>) {
342+
pub fn method_calls(expr: &Expr, max_depth: usize) -> (Vec<Symbol>, Vec<&[Expr]>, Vec<Span>) {
343343
let mut method_names = Vec::with_capacity(max_depth);
344344
let mut arg_lists = Vec::with_capacity(max_depth);
345+
let mut spans = Vec::with_capacity(max_depth);
345346

346347
let mut current = expr;
347348
for _ in 0..max_depth {
348-
if let ExprKind::MethodCall(path, _, args) = &current.node {
349+
if let ExprKind::MethodCall(path, span, args) = &current.node {
349350
if args.iter().any(|e| e.span.from_expansion()) {
350351
break;
351352
}
352353
method_names.push(path.ident.name);
353354
arg_lists.push(&**args);
355+
spans.push(*span);
354356
current = &args[0];
355357
} else {
356358
break;
357359
}
358360
}
359361

360-
(method_names, arg_lists)
362+
(method_names, arg_lists, spans)
361363
}
362364

363365
/// Matches an `Expr` against a chain of methods, and return the matched `Expr`s.

0 commit comments

Comments
 (0)