diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-17 09:23:26 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-17 09:23:26 +0000 |
| commit | 98143da79924fe2044acae749ffb01923f2f14c6 (patch) | |
| tree | c3a32eb54c9ec4919bfe5b00273345e3c82e0121 | |
| parent | 3bff42fd142b85d623c2e58e3eeb4335139599c9 (diff) | |
| parent | 0141f28475f246d615fb5a8e1d86ca3b9f666c3b (diff) | |
| download | rust-98143da79924fe2044acae749ffb01923f2f14c6.tar.gz rust-98143da79924fe2044acae749ffb01923f2f14c6.zip | |
Merge #11735
11735: Fix const generic panic, again r=lnicola a=HKalbasi fix https://github.com/rust-analyzer/rust-analyzer/pull/11734#issuecomment-1070526085 Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
| -rw-r--r-- | crates/hir_ty/src/lower.rs | 2 | ||||
| -rw-r--r-- | crates/hir_ty/src/tests/regression.rs | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 9e69785ac29..0854d065483 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -712,7 +712,7 @@ impl<'a> TyLoweringContext<'a> { .filter(|arg| !matches!(arg, GenericArg::Lifetime(_))) .skip(skip) .take(expected_num) - .zip(def_generics.iter_id().skip(skip)) + .zip(def_generics.iter_id().skip(parent_params + skip)) { if let Some(x) = generic_arg_to_chalk( self.db, diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 63faecbfafa..7a7470fd354 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -1454,3 +1454,26 @@ fn regression_11688_1() { "#, ); } + +#[test] +fn regression_11688_2() { + check_types( + r#" + union MaybeUninit<T> { + uninit: (), + value: T, + } + + impl<T> MaybeUninit<T> { + fn uninit_array<const LEN: usize>() -> [Self; LEN] { + loop {} + } + } + + fn main() { + let x = MaybeUninit::<i32>::uninit_array::<1>(); + //^ [MaybeUninit<i32>; 1] + } + "#, + ); +} |
