mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
fix const generic panic
This commit is contained in:
parent
b301b040f5
commit
1f3d18718c
2 changed files with 37 additions and 3 deletions
|
@ -1088,9 +1088,20 @@ impl<'a> InferenceContext<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let supplied_params = substs.len();
|
for (id, data) in def_generics.iter().skip(substs.len()) {
|
||||||
for _ in supplied_params..total_len {
|
match data {
|
||||||
substs.push(GenericArgData::Ty(self.table.new_type_var()).intern(Interner));
|
TypeOrConstParamData::TypeParamData(_) => {
|
||||||
|
substs.push(GenericArgData::Ty(self.table.new_type_var()).intern(Interner))
|
||||||
|
}
|
||||||
|
TypeOrConstParamData::ConstParamData(_) => {
|
||||||
|
substs.push(
|
||||||
|
GenericArgData::Const(self.table.new_const_var(
|
||||||
|
self.db.const_param_ty(ConstParamId::from_unchecked(id)),
|
||||||
|
))
|
||||||
|
.intern(Interner),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assert_eq!(substs.len(), total_len);
|
assert_eq!(substs.len(), total_len);
|
||||||
Substitution::from_iter(Interner, substs)
|
Substitution::from_iter(Interner, substs)
|
||||||
|
|
|
@ -1431,3 +1431,26 @@ fn nalgebra_factorial() {
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn regression_11688_1() {
|
||||||
|
check_no_mismatches(
|
||||||
|
r#"
|
||||||
|
pub struct Buffer<T>(T);
|
||||||
|
type Writer = Buffer<u8>;
|
||||||
|
impl<T> Buffer<T> {
|
||||||
|
fn extend_from_array<const N: usize>(&mut self, xs: &[T; N]) {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trait Encode<S> {
|
||||||
|
fn encode(self, w: &mut Writer, s: &mut S);
|
||||||
|
}
|
||||||
|
impl<S> Encode<S> for u8 {
|
||||||
|
fn encode(self, w: &mut Writer, _: &mut S) {
|
||||||
|
w.extend_from_array(&self.to_le_bytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue