Skip to content

Commit 3f0f10a

Browse files
committed
retrieve outlives constraints from inferctxt
1 parent 1357af3 commit 3f0f10a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/librustc_infer/infer/region_constraints/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir::def_id::DefId;
1313
use rustc_index::vec::IndexVec;
1414
use rustc_middle::ty::ReStatic;
1515
use rustc_middle::ty::{self, Ty, TyCtxt};
16-
use rustc_middle::ty::{ReLateBound, ReVar};
16+
use rustc_middle::ty::{OutlivesPredicate, ReLateBound, ReVar, RegionKind};
1717
use rustc_middle::ty::{Region, RegionVid};
1818
use rustc_span::Span;
1919

@@ -137,14 +137,23 @@ pub enum Constraint<'tcx> {
137137
RegSubReg(Region<'tcx>, Region<'tcx>),
138138
}
139139

140-
impl Constraint<'_> {
140+
impl<'tcx> Constraint<'tcx> {
141141
pub fn involves_placeholders(&self) -> bool {
142142
match self {
143143
Constraint::VarSubVar(_, _) => false,
144144
Constraint::VarSubReg(_, r) | Constraint::RegSubVar(r, _) => r.is_placeholder(),
145145
Constraint::RegSubReg(r, s) => r.is_placeholder() || s.is_placeholder(),
146146
}
147147
}
148+
149+
pub fn to_region_outlives_predicate(self) -> OutlivesPredicate<RegionKind, RegionKind> {
150+
match self {
151+
Self::VarSubVar(a, b) => OutlivesPredicate(RegionKind::ReVar(a), RegionKind::ReVar(b)),
152+
Self::RegSubVar(a, b) => OutlivesPredicate(*a, RegionKind::ReVar(b)),
153+
Self::VarSubReg(a, b) => OutlivesPredicate(RegionKind::ReVar(a), *b),
154+
Self::RegSubReg(a, b) => OutlivesPredicate(*a, *b),
155+
}
156+
}
148157
}
149158

150159
/// `VerifyGenericBound(T, _, R, RS)`: the parameter type `T` (or

src/librustc_typeck/check/generator_interior.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ pub fn resolve_interior<'a, 'tcx>(
188188

189189
// Extract type components to build the witness type.
190190
let type_list = fcx.tcx.mk_type_list(type_causes.iter().map(|cause| cause.ty));
191+
let _region_constraints = visitor.fcx.with_region_constraints(|constraints_data| {
192+
constraints_data
193+
.constraints
194+
.keys()
195+
.map(|constraints| constraints.to_region_outlives_predicate())
196+
.collect::<Vec<_>>()
197+
});
198+
199+
debug!("region outlives inside generator: {:?}", _region_constraints);
200+
191201
let witness = fcx.tcx.mk_generator_witness(ty::Binder::bind(type_list));
192202

193203
// Store the generator types and spans into the tables for this generator.

0 commit comments

Comments
 (0)