Unnamed repository; edit this file 'description' to name the repository.
fix: Correct type_or_const param index bound in debug_assert
local_id is used as an index into type/const params; valid indices are 0..len_type_or_consts(). The previous <= check incorrectly allowed idx == len. Assisted by an AI coding tool (see CONTRIBUTING.md).
Weixie Cui 7 weeks ago
parent 9253d39 · commit 834ad9c
-rw-r--r--crates/hir-ty/src/generics.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/hir-ty/src/generics.rs b/crates/hir-ty/src/generics.rs
index b1500bcdb7..b3c888da8e 100644
--- a/crates/hir-ty/src/generics.rs
+++ b/crates/hir-ty/src/generics.rs
@@ -185,7 +185,7 @@ impl Generics {
if param.parent == self.def {
let idx = param.local_id.into_raw().into_u32() as usize;
debug_assert!(
- idx <= self.params.len_type_or_consts(),
+ idx < self.params.len_type_or_consts(),
"idx: {} len: {}",
idx,
self.params.len_type_or_consts()