resolve regions before implied bounds

This commit is contained in:
Ali MJ Al-Nasrawy 2023-02-01 13:52:44 +03:00
parent 95bcca85ff
commit 4e441565e2

View File

@ -3,7 +3,8 @@
use crate::traits::query::NoSolution; use crate::traits::query::NoSolution;
use crate::traits::ObligationCause; use crate::traits::ObligationCause;
use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::fx::FxIndexSet;
use rustc_middle::ty::{self, ParamEnv, Ty}; use rustc_infer::infer::resolve::OpportunisticRegionResolver;
use rustc_middle::ty::{self, ParamEnv, Ty, TypeFolder, TypeVisitableExt};
use rustc_span::def_id::LocalDefId; use rustc_span::def_id::LocalDefId;
pub use rustc_middle::traits::query::OutlivesBound; pub use rustc_middle::traits::query::OutlivesBound;
@ -52,6 +53,10 @@ fn implied_outlives_bounds(
body_id: LocalDefId, body_id: LocalDefId,
ty: Ty<'tcx>, ty: Ty<'tcx>,
) -> Vec<OutlivesBound<'tcx>> { ) -> Vec<OutlivesBound<'tcx>> {
let ty = self.resolve_vars_if_possible(ty);
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty);
assert!(!ty.needs_infer());
let span = self.tcx.def_span(body_id); let span = self.tcx.def_span(body_id);
let result = param_env let result = param_env
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty }) .and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
@ -105,10 +110,7 @@ fn implied_bounds_tys(
tys: FxIndexSet<Ty<'tcx>>, tys: FxIndexSet<Ty<'tcx>>,
) -> Bounds<'a, 'tcx> { ) -> Bounds<'a, 'tcx> {
tys.into_iter() tys.into_iter()
.map(move |ty| { .map(move |ty| self.implied_outlives_bounds(param_env, body_id, ty))
let ty = self.resolve_vars_if_possible(ty);
self.implied_outlives_bounds(param_env, body_id, ty)
})
.flatten() .flatten()
} }
} }