aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-22 13:32:12 +0100
committerGitHub <[email protected]>2021-05-22 13:32:12 +0100
commit057e2ed574bb54afeca35f032774bb8b94aaa1d1 (patch)
treefa4c9d439d9df245e16869e88f4ceceed26b3dde /crates/hir_ty/src/infer
parent7d81e40e36a7b5451785e224a2f16822834f29a3 (diff)
parent63614aafad6bfe984e67a9b9106b31decb3b59f4 (diff)
Merge #8921
8921: Resolve any lifetime variables to 'static after inference r=flodiebold a=flodiebold 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. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer')
-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}