From e652fe1ece642b354689336ac47d728bfc45783e Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sun, 4 Jul 2021 14:24:02 -0500 Subject: [PATCH] [WIP] Force projection sub-obligations to `EvaluatedToOkModuloRegions` --- .../rustc_trait_selection/src/traits/project.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 352829234a41a..d8f5c18391037 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -553,7 +553,7 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>( debug!(?projected_ty, ?depth, ?projected_obligations); - let result = if projected_ty.has_projections() { + let mut result = if projected_ty.has_projections() { let mut normalizer = AssocTypeNormalizer::new( selcx, param_env, @@ -570,7 +570,17 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>( Normalized { value: projected_ty, obligations: projected_obligations } }; - let cache_value = prune_cache_value_obligations(infcx, &result); + let mut cache_value = prune_cache_value_obligations(infcx, &result); + if !result.obligations.is_empty() { + let dummy_pred = + infcx.tcx.mk_predicate(ty::Binder::dummy(ty::PredicateKind::RegionOutlives( + ty::OutlivesPredicate(&ty::ReStatic, &ty::ReStatic), + ))); + let dummy = + Obligation::new(ObligationCause::dummy(), ty::ParamEnv::empty(), dummy_pred); + cache_value.obligations.push(dummy.clone()); + result.obligations.push(dummy); + } infcx.inner.borrow_mut().projection_cache().insert_ty(cache_key, cache_value); obligations.extend(result.obligations); Ok(Some(result.value))