diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-08-03 21:43:17 +0200 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-08-04 13:17:39 +0200 |
| commit | ed0dfed24f988cb2b52c819cd57c8eb65da400be (patch) | |
| tree | 6ef1c4ae20455b74511aa0fb1f25f27c78c25dd9 /clippy_lints/src/temporary_assignment.rs | |
| parent | ff27f9095f5edebdd03e885cb4df74ad32df30dc (diff) | |
| download | rust-ed0dfed24f988cb2b52c819cd57c8eb65da400be.tar.gz rust-ed0dfed24f988cb2b52c819cd57c8eb65da400be.zip | |
Improve spans for indexing expressions
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
Diffstat (limited to 'clippy_lints/src/temporary_assignment.rs')
| -rw-r--r-- | clippy_lints/src/temporary_assignment.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clippy_lints/src/temporary_assignment.rs b/clippy_lints/src/temporary_assignment.rs index 3766b8f8ed1..b6b653f6610 100644 --- a/clippy_lints/src/temporary_assignment.rs +++ b/clippy_lints/src/temporary_assignment.rs @@ -33,7 +33,7 @@ impl<'tcx> LateLintPass<'tcx> for TemporaryAssignment { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let ExprKind::Assign(target, ..) = &expr.kind { let mut base = target; - while let ExprKind::Field(f, _) | ExprKind::Index(f, _) = &base.kind { + while let ExprKind::Field(f, _) | ExprKind::Index(f, _, _) = &base.kind { base = f; } if is_temporary(base) && !is_adjusted(cx, base) { |
