2023-12-18 22:45:34 +00:00
|
|
|
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
|
|
|
use rustc_infer::infer::{InferCtxt, RegionResolutionError};
|
|
|
|
use rustc_middle::traits::ObligationCause;
|
|
|
|
|
|
|
|
pub trait InferCtxtRegionExt<'tcx> {
|
|
|
|
/// Resolve regions, using the deep normalizer to normalize any type-outlives
|
|
|
|
/// obligations in the process. This is in `rustc_trait_selection` because
|
|
|
|
/// we need to normalize.
|
|
|
|
///
|
|
|
|
/// Prefer this method over `resolve_regions_with_normalize`, unless you are
|
|
|
|
/// doing something specific for normalization.
|
|
|
|
fn resolve_regions(
|
|
|
|
&self,
|
|
|
|
outlives_env: &OutlivesEnvironment<'tcx>,
|
|
|
|
) -> Vec<RegionResolutionError<'tcx>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'tcx> InferCtxtRegionExt<'tcx> for InferCtxt<'tcx> {
|
|
|
|
fn resolve_regions(
|
|
|
|
&self,
|
|
|
|
outlives_env: &OutlivesEnvironment<'tcx>,
|
|
|
|
) -> Vec<RegionResolutionError<'tcx>> {
|
2024-01-26 19:18:14 +00:00
|
|
|
self.resolve_regions_with_normalize(outlives_env, |ty, origin| {
|
2023-12-18 22:45:34 +00:00
|
|
|
let ty = self.resolve_vars_if_possible(ty);
|
|
|
|
|
|
|
|
if self.next_trait_solver() {
|
2024-01-30 21:48:54 +00:00
|
|
|
crate::solve::deeply_normalize_with_skipped_universes(
|
2024-01-26 19:18:14 +00:00
|
|
|
self.at(
|
|
|
|
&ObligationCause::dummy_with_span(origin.span()),
|
|
|
|
outlives_env.param_env,
|
|
|
|
),
|
2023-12-18 22:45:34 +00:00
|
|
|
ty,
|
2024-01-30 21:48:54 +00:00
|
|
|
vec![None; ty.outer_exclusive_binder().as_usize()],
|
2023-12-18 22:45:34 +00:00
|
|
|
)
|
|
|
|
.map_err(|_| ty)
|
|
|
|
} else {
|
|
|
|
Ok(ty)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|