Rollup merge of #143901 - compiler-errors:region-constraint-nits, r=lcnr
Region constraint nits Couple miscellaneous region constraints that have a bit to do with rust-lang/rust#143545 but stand on their own.
This commit is contained in:
commit
8fcef5674a
6 changed files with 19 additions and 24 deletions
|
|
@ -159,6 +159,9 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
|||
}
|
||||
|
||||
GenericArgKind::Type(mut t1) => {
|
||||
// Scraped constraints may have had inference vars.
|
||||
t1 = self.infcx.resolve_vars_if_possible(t1);
|
||||
|
||||
// Normalize the type we receive from a `TypeOutlives` obligation
|
||||
// in the new trait solver.
|
||||
if infcx.next_trait_solver() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ use std::iter;
|
|||
use rustc_index::{Idx, IndexVec};
|
||||
use rustc_middle::arena::ArenaAllocatable;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::mir::ConstraintCategory;
|
||||
use rustc_middle::ty::{self, BoundVar, GenericArg, GenericArgKind, Ty, TyCtxt, TypeFoldable};
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
|
|
@ -23,7 +22,9 @@ use crate::infer::canonical::{
|
|||
QueryRegionConstraints, QueryResponse,
|
||||
};
|
||||
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
|
||||
use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult, SubregionOrigin};
|
||||
use crate::infer::{
|
||||
DefineOpaqueTypes, InferCtxt, InferOk, InferResult, SubregionOrigin, TypeOutlivesConstraint,
|
||||
};
|
||||
use crate::traits::query::NoSolution;
|
||||
use crate::traits::{ObligationCause, PredicateObligations, ScrubbedTraitError, TraitEngine};
|
||||
|
||||
|
|
@ -117,13 +118,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
let region_obligations = self.take_registered_region_obligations();
|
||||
debug!(?region_obligations);
|
||||
let region_constraints = self.with_region_constraints(|region_constraints| {
|
||||
make_query_region_constraints(
|
||||
tcx,
|
||||
region_obligations
|
||||
.iter()
|
||||
.map(|r_o| (r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())),
|
||||
region_constraints,
|
||||
)
|
||||
make_query_region_constraints(tcx, region_obligations, region_constraints)
|
||||
});
|
||||
debug!(?region_constraints);
|
||||
|
||||
|
|
@ -570,7 +565,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
/// creates query region constraints.
|
||||
pub fn make_query_region_constraints<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>, ConstraintCategory<'tcx>)>,
|
||||
outlives_obligations: Vec<TypeOutlivesConstraint<'tcx>>,
|
||||
region_constraints: &RegionConstraintData<'tcx>,
|
||||
) -> QueryRegionConstraints<'tcx> {
|
||||
let RegionConstraintData { constraints, verifys } = region_constraints;
|
||||
|
|
@ -599,8 +594,11 @@ pub fn make_query_region_constraints<'tcx>(
|
|||
};
|
||||
(constraint, origin.to_constraint_category())
|
||||
})
|
||||
.chain(outlives_obligations.map(|(ty, r, constraint_category)| {
|
||||
(ty::OutlivesPredicate(ty.into(), r), constraint_category)
|
||||
.chain(outlives_obligations.into_iter().map(|obl| {
|
||||
(
|
||||
ty::OutlivesPredicate(obl.sup_type.into(), obl.sub_region),
|
||||
obl.origin.to_constraint_category(),
|
||||
)
|
||||
}))
|
||||
.collect();
|
||||
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
|
||||
/// Trait queries just want to pass back type obligations "as is"
|
||||
pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
|
||||
assert!(!self.in_snapshot(), "cannot take registered region obligations in a snapshot");
|
||||
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use std::assert_matches::assert_matches;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use rustc_data_structures::undo_log::{Rollback, UndoLogs};
|
||||
|
|
@ -73,7 +74,8 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for InferCtxtInner<'tcx> {
|
|||
}
|
||||
UndoLog::ProjectionCache(undo) => self.projection_cache.reverse(undo),
|
||||
UndoLog::PushTypeOutlivesConstraint => {
|
||||
self.region_obligations.pop();
|
||||
let popped = self.region_obligations.pop();
|
||||
assert_matches!(popped, Some(_), "pushed region constraint but could not pop it");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,13 +213,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
|
|||
// inside of a `probe` whenever we have multiple choices inside of the solver.
|
||||
let region_obligations = self.0.inner.borrow().region_obligations().to_owned();
|
||||
let region_constraints = self.0.with_region_constraints(|region_constraints| {
|
||||
make_query_region_constraints(
|
||||
self.tcx,
|
||||
region_obligations
|
||||
.iter()
|
||||
.map(|r_o| (r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category())),
|
||||
region_constraints,
|
||||
)
|
||||
make_query_region_constraints(self.tcx, region_obligations, region_constraints)
|
||||
});
|
||||
|
||||
let mut seen = FxHashSet::default();
|
||||
|
|
|
|||
|
|
@ -103,10 +103,7 @@ where
|
|||
let region_constraint_data = infcx.take_and_reset_region_constraints();
|
||||
let region_constraints = query_response::make_query_region_constraints(
|
||||
infcx.tcx,
|
||||
region_obligations
|
||||
.iter()
|
||||
.map(|r_o| (r_o.sup_type, r_o.sub_region, r_o.origin.to_constraint_category()))
|
||||
.map(|(ty, r, cc)| (infcx.resolve_vars_if_possible(ty), r, cc)),
|
||||
region_obligations,
|
||||
®ion_constraint_data,
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue