Skip to content

Commit d1743c9

Browse files
committed
resolve regions before implied bounds
1 parent b197f1a commit d1743c9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/rustc_trait_selection/src/traits/outlives_bounds.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::traits::query::type_op::{self, TypeOp, TypeOpOutput};
33
use crate::traits::query::NoSolution;
44
use crate::traits::{ObligationCause, ObligationCtxt};
55
use rustc_data_structures::fx::FxIndexSet;
6-
use rustc_middle::ty::{self, ParamEnv, Ty};
6+
use rustc_infer::infer::resolve::OpportunisticRegionResolver;
7+
use rustc_middle::ty::{self, ParamEnv, Ty, TypeFolder, TypeVisitableExt};
78
use rustc_span::def_id::LocalDefId;
89

910
pub use rustc_middle::traits::query::OutlivesBound;
@@ -52,6 +53,10 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
5253
body_id: LocalDefId,
5354
ty: Ty<'tcx>,
5455
) -> Vec<OutlivesBound<'tcx>> {
56+
let ty = self.resolve_vars_if_possible(ty);
57+
let ty = OpportunisticRegionResolver::new(self).fold_ty(ty);
58+
assert!(!ty.needs_infer());
59+
5560
let span = self.tcx.def_span(body_id);
5661
let result = param_env
5762
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
@@ -106,10 +111,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
106111
tys: FxIndexSet<Ty<'tcx>>,
107112
) -> Bounds<'a, 'tcx> {
108113
tys.into_iter()
109-
.map(move |ty| {
110-
let ty = self.resolve_vars_if_possible(ty);
111-
self.implied_outlives_bounds(param_env, body_id, ty)
112-
})
114+
.map(move |ty| self.implied_outlives_bounds(param_env, body_id, ty))
113115
.flatten()
114116
}
115117
}

0 commit comments

Comments
 (0)