Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22601 from Wilfred/fix/static-array-len-alias-panic
fix: Crash on static constants in array length positions
Chayim Refael Friedman 4 weeks ago
parent d580e2a · parent 39ae531 · commit abb1301
-rw-r--r--crates/hir-ty/src/next_solver/interner.rs3
-rw-r--r--crates/hir-ty/src/tests/regression/new_solver.rs10
2 files changed, 13 insertions, 0 deletions
diff --git a/crates/hir-ty/src/next_solver/interner.rs b/crates/hir-ty/src/next_solver/interner.rs
index b466fe0f18..9875a915dc 100644
--- a/crates/hir-ty/src/next_solver/interner.rs
+++ b/crates/hir-ty/src/next_solver/interner.rs
@@ -1128,6 +1128,9 @@ impl<'db> Interner for DbInterner<'db> {
SolverDefId::ConstId(def_id) => {
AliasTermKind::UnevaluatedConst { def_id: GeneralConstIdWrapper(def_id.into()) }
}
+ SolverDefId::StaticId(def_id) => {
+ AliasTermKind::UnevaluatedConst { def_id: GeneralConstIdWrapper(def_id.into()) }
+ }
SolverDefId::AnonConstId(def_id) => {
AliasTermKind::UnevaluatedConst { def_id: GeneralConstIdWrapper(def_id.into()) }
}
diff --git a/crates/hir-ty/src/tests/regression/new_solver.rs b/crates/hir-ty/src/tests/regression/new_solver.rs
index c77b20f4b5..17127b2771 100644
--- a/crates/hir-ty/src/tests/regression/new_solver.rs
+++ b/crates/hir-ty/src/tests/regression/new_solver.rs
@@ -395,6 +395,16 @@ fn main() {
}
#[test]
+fn static_as_array_len_does_not_panic() {
+ check_no_mismatches(
+ r#"
+static S: usize = 8;
+const A: [u8; S] = [0; 8];
+ "#,
+ );
+}
+
+#[test]
fn another_20654_case() {
check_no_mismatches(
r#"