mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
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;
|
||||
pub use rustc_type_ir::solve::*;
|
||||
|
||||
use crate::infer::canonical::QueryRegionConstraints;
|
||||
use crate::ty::{
|
||||
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)]
|
||||
pub struct ExternalConstraintsData<'tcx> {
|
||||
// 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 normalization_nested_goals: NestedNormalizationGoals<'tcx>,
|
||||
}
|
||||
|
@ -135,8 +135,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
||||
// Remove any trivial region constraints once we've resolved regions
|
||||
external_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(
|
||||
self.infcx,
|
||||
@ -193,19 +192,23 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
||||
// 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.
|
||||
let region_obligations = self.infcx.inner.borrow().region_obligations().to_owned();
|
||||
let mut region_constraints = self.infcx.with_region_constraints(|region_constraints| {
|
||||
make_query_region_constraints(
|
||||
self.interner(),
|
||||
region_obligations.iter().map(|r_o| {
|
||||
(r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())
|
||||
}),
|
||||
region_constraints,
|
||||
)
|
||||
});
|
||||
|
||||
let QueryRegionConstraints { outlives, member_constraints } =
|
||||
self.infcx.with_region_constraints(|region_constraints| {
|
||||
make_query_region_constraints(
|
||||
self.interner(),
|
||||
region_obligations.iter().map(|r_o| {
|
||||
(r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())
|
||||
}),
|
||||
region_constraints,
|
||||
)
|
||||
});
|
||||
assert_eq!(member_constraints, vec![]);
|
||||
let mut seen = FxHashSet::default();
|
||||
region_constraints.outlives.retain(|outlives| seen.insert(*outlives));
|
||||
region_constraints
|
||||
outlives
|
||||
.into_iter()
|
||||
.filter(|(outlives, _)| seen.insert(*outlives))
|
||||
.map(|(outlives, _origin)| outlives)
|
||||
.collect()
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
@ -369,16 +372,17 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
||||
}
|
||||
}
|
||||
|
||||
fn register_region_constraints(&mut self, region_constraints: &QueryRegionConstraints<'tcx>) {
|
||||
for &(ty::OutlivesPredicate(lhs, rhs), _) in ®ion_constraints.outlives {
|
||||
fn register_region_constraints(
|
||||
&mut self,
|
||||
outlives: &[ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>],
|
||||
) {
|
||||
for &ty::OutlivesPredicate(lhs, rhs) in outlives {
|
||||
match lhs.unpack() {
|
||||
GenericArgKind::Lifetime(lhs) => self.register_region_outlives(lhs, rhs),
|
||||
GenericArgKind::Type(lhs) => self.register_ty_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>)]) {
|
||||
|
Loading…
Reference in New Issue
Block a user