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/index_refutable_slice.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/index_refutable_slice.rs')
| -rw-r--r-- | clippy_lints/src/index_refutable_slice.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 01a7c497cbe..f507f45d5bb 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -254,7 +254,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> { // Checking for slice indexing let parent_id = map.parent_id(expr.hir_id); if let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id); - if let hir::ExprKind::Index(_, index_expr) = parent_expr.kind; + if let hir::ExprKind::Index(_, index_expr, _) = parent_expr.kind; if let Some(Constant::Int(index_value)) = constant(cx, cx.typeck_results(), index_expr); if let Ok(index_value) = index_value.try_into(); if index_value < max_suggested_slice; |
