mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Merge #9975
9975: minor: Fix panic caused by #9966 r=flodiebold a=flodiebold Chalk can introduce new type variables when doing lazy normalization, so we have to do the proper 'fudging' after all. Co-authored-by: Florian Diebold <flodiebold@gmail.com>
This commit is contained in:
commit
9e3517f8f3
3 changed files with 129 additions and 17 deletions
|
@ -986,20 +986,21 @@ impl<'a> InferenceContext<'a> {
|
|||
inputs: Vec<Ty>,
|
||||
) -> Vec<Ty> {
|
||||
if let Some(expected_ty) = expected_output.to_option(&mut self.table) {
|
||||
let snapshot = self.table.snapshot();
|
||||
let result = if self.table.try_unify(&expected_ty, &output).is_ok() {
|
||||
// FIXME: the unification could introduce lifetime variables, which we'd need to handle here
|
||||
self.table.resolve_with_fallback(inputs, |var, kind, _, _| match kind {
|
||||
chalk_ir::VariableKind::Ty(tk) => var.to_ty(&Interner, tk).cast(&Interner),
|
||||
chalk_ir::VariableKind::Lifetime => var.to_lifetime(&Interner).cast(&Interner),
|
||||
chalk_ir::VariableKind::Const(ty) => {
|
||||
var.to_const(&Interner, ty).cast(&Interner)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
self.table.rollback_to(snapshot);
|
||||
let result = self.table.fudge_inference(|table| {
|
||||
if table.try_unify(&expected_ty, &output).is_ok() {
|
||||
table.resolve_with_fallback(inputs, |var, kind, _, _| match kind {
|
||||
chalk_ir::VariableKind::Ty(tk) => var.to_ty(&Interner, tk).cast(&Interner),
|
||||
chalk_ir::VariableKind::Lifetime => {
|
||||
var.to_lifetime(&Interner).cast(&Interner)
|
||||
}
|
||||
chalk_ir::VariableKind::Const(ty) => {
|
||||
var.to_const(&Interner, ty).cast(&Interner)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Vec::new()
|
||||
}
|
||||
});
|
||||
result
|
||||
} else {
|
||||
Vec::new()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue