aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-05-22 13:25:58 +0100
committerFlorian Diebold <[email protected]>2021-05-22 13:27:22 +0100
commit63614aafad6bfe984e67a9b9106b31decb3b59f4 (patch)
tree8d6a0e4cb54cbef23765d23a18214f214db1dc14
parent3cfe2d0a5d663d29c3d196f9d16e91964780792a (diff)
Resolve any lifetime variables to 'static after inference
Chalk's unification can sometimes create lifetime variables, which we currently don't really deal with, but at least we don't want to leak them outside of inference. Should fix #8919.
-rw-r--r--crates/hir_ty/src/infer/unify.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs
index 21d3fb54e..f8233cac3 100644
--- a/crates/hir_ty/src/infer/unify.rs
+++ b/crates/hir_ty/src/infer/unify.rs
@@ -435,7 +435,7 @@ mod resolve {
435 use super::InferenceTable; 435 use super::InferenceTable;
436 use crate::{ 436 use crate::{
437 ConcreteConst, Const, ConstData, ConstValue, DebruijnIndex, GenericArg, InferenceVar, 437 ConcreteConst, Const, ConstData, ConstValue, DebruijnIndex, GenericArg, InferenceVar,
438 Interner, Ty, TyVariableKind, VariableKind, 438 Interner, Lifetime, Ty, TyVariableKind, VariableKind,
439 }; 439 };
440 use chalk_ir::{ 440 use chalk_ir::{
441 cast::Cast, 441 cast::Cast,
@@ -524,5 +524,17 @@ mod resolve {
524 }; 524 };
525 Ok(result) 525 Ok(result)
526 } 526 }
527
528 fn fold_inference_lifetime(
529 &mut self,
530 _var: InferenceVar,
531 _outer_binder: DebruijnIndex,
532 ) -> Fallible<Lifetime> {
533 // fall back all lifetimes to 'static -- currently we don't deal
534 // with any lifetimes, but we can sometimes get some lifetime
535 // variables through Chalk's unification, and this at least makes
536 // sure we don't leak them outside of inference
537 Ok(crate::static_lifetime())
538 }
527 } 539 }
528} 540}