diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-05-26 10:38:02 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-05-28 10:03:01 +0000 |
| commit | 013ab6cdb116a4c194ef5ed5fdeda55e68d49fe7 (patch) | |
| tree | e72116ad86c102162033fc4122fbff41b8e9cdaf /clippy_lints/src/index_refutable_slice.rs | |
| parent | ce0adf08c9c08a770fa65c98cdb59335d4acee3d (diff) | |
| download | rust-013ab6cdb116a4c194ef5ed5fdeda55e68d49fe7.tar.gz rust-013ab6cdb116a4c194ef5ed5fdeda55e68d49fe7.zip | |
Use `builin_index` instead of hand-rolling it
Diffstat (limited to 'clippy_lints/src/index_refutable_slice.rs')
| -rw-r--r-- | clippy_lints/src/index_refutable_slice.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clippy_lints/src/index_refutable_slice.rs b/clippy_lints/src/index_refutable_slice.rs index 0b1cae30ca5..3d131a7825a 100644 --- a/clippy_lints/src/index_refutable_slice.rs +++ b/clippy_lints/src/index_refutable_slice.rs @@ -12,7 +12,6 @@ use rustc_hir::HirId; use rustc_hir::intravisit::{self, Visitor}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::nested_filter; -use rustc_middle::ty; use rustc_session::impl_lint_pass; use rustc_span::Span; use rustc_span::symbol::Ident; @@ -109,11 +108,11 @@ fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<Hir } let bound_ty = cx.typeck_results().node_type(pat.hir_id); - if let ty::Slice(inner_ty) | ty::Array(inner_ty, _) = bound_ty.peel_refs().kind() { + if let Some(inner_ty) = bound_ty.peel_refs().builtin_index() { // The values need to use the `ref` keyword if they can't be copied. // This will need to be adjusted if the lint want to support mutable access in the future let src_is_ref = bound_ty.is_ref() && by_ref == hir::ByRef::No; - let needs_ref = !(src_is_ref || is_copy(cx, *inner_ty)); + let needs_ref = !(src_is_ref || is_copy(cx, inner_ty)); let slice_info = slices .entry(value_hir_id) |
