From 63614aafad6bfe984e67a9b9106b31decb3b59f4 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 22 May 2021 14:25:58 +0200 Subject: 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. --- crates/hir_ty/src/infer/unify.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crates') 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 { use super::InferenceTable; use crate::{ ConcreteConst, Const, ConstData, ConstValue, DebruijnIndex, GenericArg, InferenceVar, - Interner, Ty, TyVariableKind, VariableKind, + Interner, Lifetime, Ty, TyVariableKind, VariableKind, }; use chalk_ir::{ cast::Cast, @@ -524,5 +524,17 @@ mod resolve { }; Ok(result) } + + fn fold_inference_lifetime( + &mut self, + _var: InferenceVar, + _outer_binder: DebruijnIndex, + ) -> Fallible { + // fall back all lifetimes to 'static -- currently we don't deal + // with any lifetimes, but we can sometimes get some lifetime + // variables through Chalk's unification, and this at least makes + // sure we don't leak them outside of inference + Ok(crate::static_lifetime()) + } } } -- cgit v1.2.3