Make ExternalConstraints just carry outlives
This commit is contained in:
parent
a333943890
commit
f93ee19fd7
@ -4,7 +4,6 @@ use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
|
|||||||
use rustc_type_ir as ir;
|
use rustc_type_ir as ir;
|
||||||
pub use rustc_type_ir::solve::*;
|
pub use rustc_type_ir::solve::*;
|
||||||
|
|
||||||
use crate::infer::canonical::QueryRegionConstraints;
|
|
||||||
use crate::ty::{
|
use crate::ty::{
|
||||||
self, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeVisitable, TypeVisitor,
|
self, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeVisitable, TypeVisitor,
|
||||||
};
|
};
|
||||||
@ -52,7 +51,7 @@ impl<'tcx> std::ops::Deref for ExternalConstraints<'tcx> {
|
|||||||
#[derive(Debug, PartialEq, Eq, Clone, Hash, HashStable, Default, TypeVisitable, TypeFoldable)]
|
#[derive(Debug, PartialEq, Eq, Clone, Hash, HashStable, Default, TypeVisitable, TypeFoldable)]
|
||||||
pub struct ExternalConstraintsData<'tcx> {
|
pub struct ExternalConstraintsData<'tcx> {
|
||||||
// FIXME: implement this.
|
// FIXME: implement this.
|
||||||
pub region_constraints: QueryRegionConstraints<'tcx>,
|
pub region_constraints: Vec<ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>>,
|
||||||
pub opaque_types: Vec<(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)>,
|
pub opaque_types: Vec<(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)>,
|
||||||
pub normalization_nested_goals: NestedNormalizationGoals<'tcx>,
|
pub normalization_nested_goals: NestedNormalizationGoals<'tcx>,
|
||||||
}
|
}
|
||||||
|
@ -135,8 +135,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
|||||||
// Remove any trivial region constraints once we've resolved regions
|
// Remove any trivial region constraints once we've resolved regions
|
||||||
external_constraints
|
external_constraints
|
||||||
.region_constraints
|
.region_constraints
|
||||||
.outlives
|
.retain(|outlives| outlives.0.as_region().map_or(true, |re| re != outlives.1));
|
||||||
.retain(|(outlives, _)| outlives.0.as_region().map_or(true, |re| re != outlives.1));
|
|
||||||
|
|
||||||
let canonical = Canonicalizer::canonicalize(
|
let canonical = Canonicalizer::canonicalize(
|
||||||
self.infcx,
|
self.infcx,
|
||||||
@ -193,19 +192,23 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
|||||||
// Cannot use `take_registered_region_obligations` as we may compute the response
|
// Cannot use `take_registered_region_obligations` as we may compute the response
|
||||||
// inside of a `probe` whenever we have multiple choices inside of the solver.
|
// inside of a `probe` whenever we have multiple choices inside of the solver.
|
||||||
let region_obligations = self.infcx.inner.borrow().region_obligations().to_owned();
|
let region_obligations = self.infcx.inner.borrow().region_obligations().to_owned();
|
||||||
let mut region_constraints = self.infcx.with_region_constraints(|region_constraints| {
|
let QueryRegionConstraints { outlives, member_constraints } =
|
||||||
make_query_region_constraints(
|
self.infcx.with_region_constraints(|region_constraints| {
|
||||||
self.interner(),
|
make_query_region_constraints(
|
||||||
region_obligations.iter().map(|r_o| {
|
self.interner(),
|
||||||
(r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())
|
region_obligations.iter().map(|r_o| {
|
||||||
}),
|
(r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())
|
||||||
region_constraints,
|
}),
|
||||||
)
|
region_constraints,
|
||||||
});
|
)
|
||||||
|
});
|
||||||
|
assert_eq!(member_constraints, vec![]);
|
||||||
let mut seen = FxHashSet::default();
|
let mut seen = FxHashSet::default();
|
||||||
region_constraints.outlives.retain(|outlives| seen.insert(*outlives));
|
outlives
|
||||||
region_constraints
|
.into_iter()
|
||||||
|
.filter(|(outlives, _)| seen.insert(*outlives))
|
||||||
|
.map(|(outlives, _origin)| outlives)
|
||||||
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
Default::default()
|
Default::default()
|
||||||
};
|
};
|
||||||
@ -369,16 +372,17 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_region_constraints(&mut self, region_constraints: &QueryRegionConstraints<'tcx>) {
|
fn register_region_constraints(
|
||||||
for &(ty::OutlivesPredicate(lhs, rhs), _) in ®ion_constraints.outlives {
|
&mut self,
|
||||||
|
outlives: &[ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>],
|
||||||
|
) {
|
||||||
|
for &ty::OutlivesPredicate(lhs, rhs) in outlives {
|
||||||
match lhs.unpack() {
|
match lhs.unpack() {
|
||||||
GenericArgKind::Lifetime(lhs) => self.register_region_outlives(lhs, rhs),
|
GenericArgKind::Lifetime(lhs) => self.register_region_outlives(lhs, rhs),
|
||||||
GenericArgKind::Type(lhs) => self.register_ty_outlives(lhs, rhs),
|
GenericArgKind::Type(lhs) => self.register_ty_outlives(lhs, rhs),
|
||||||
GenericArgKind::Const(_) => bug!("const outlives: {lhs:?}: {rhs:?}"),
|
GenericArgKind::Const(_) => bug!("const outlives: {lhs:?}: {rhs:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(region_constraints.member_constraints.is_empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_new_opaque_types(&mut self, opaque_types: &[(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)]) {
|
fn register_new_opaque_types(&mut self, opaque_types: &[(ty::OpaqueTypeKey<'tcx>, Ty<'tcx>)]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user