summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_infer/src/infer/outlives/obligations.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /compiler/rustc_infer/src/infer/outlives/obligations.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_infer/src/infer/outlives/obligations.rs')
-rw-r--r--compiler/rustc_infer/src/infer/outlives/obligations.rs47
1 files changed, 14 insertions, 33 deletions
diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs
index bbe7d4c63..ccf11c61b 100644
--- a/compiler/rustc_infer/src/infer/outlives/obligations.rs
+++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs
@@ -72,6 +72,8 @@ use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, Region, SubstsRef, Ty, TyCtxt, TypeVisitableExt};
use smallvec::smallvec;
+use super::env::OutlivesEnvironment;
+
impl<'tcx> InferCtxt<'tcx> {
/// Registers that the given region obligation must be resolved
/// from within the scope of `body_id`. These regions are enqueued
@@ -112,39 +114,17 @@ impl<'tcx> InferCtxt<'tcx> {
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
}
- /// NOTE: Prefer using `TypeErrCtxt::check_region_obligations_and_report_errors`
- /// instead of calling this directly.
- ///
/// Process the region obligations that must be proven (during
/// `regionck`) for the given `body_id`, given information about
- /// the region bounds in scope and so forth. This function must be
- /// invoked for all relevant body-ids before region inference is
- /// done (or else an assert will fire).
+ /// the region bounds in scope and so forth.
///
/// See the `region_obligations` field of `InferCtxt` for some
/// comments about how this function fits into the overall expected
/// flow of the inferencer. The key point is that it is
/// invoked after all type-inference variables have been bound --
- /// towards the end of regionck. This also ensures that the
- /// region-bound-pairs are available (see comments above regarding
- /// closures).
- ///
- /// # Parameters
- ///
- /// - `region_bound_pairs_map`: the set of region bounds implied by
- /// the parameters and where-clauses. In particular, each pair
- /// `('a, K)` in this list tells us that the bounds in scope
- /// indicate that `K: 'a`, where `K` is either a generic
- /// parameter like `T` or a projection like `T::Item`.
- /// - `param_env` is the parameter environment for the enclosing function.
- /// - `body_id` is the body-id whose region obligations are being
- /// processed.
- #[instrument(level = "debug", skip(self, region_bound_pairs))]
- pub fn process_registered_region_obligations(
- &self,
- region_bound_pairs: &RegionBoundPairs<'tcx>,
- param_env: ty::ParamEnv<'tcx>,
- ) {
+ /// right before lexical region resolution.
+ #[instrument(level = "debug", skip(self, outlives_env))]
+ pub fn process_registered_region_obligations(&self, outlives_env: &OutlivesEnvironment<'tcx>) {
assert!(
!self.in_snapshot.get(),
"cannot process registered region obligations in a snapshot"
@@ -153,15 +133,16 @@ impl<'tcx> InferCtxt<'tcx> {
let my_region_obligations = self.take_registered_region_obligations();
for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
- debug!(
- "process_registered_region_obligations: sup_type={:?} sub_region={:?} origin={:?}",
- sup_type, sub_region, origin
- );
-
+ debug!(?sup_type, ?sub_region, ?origin);
let sup_type = self.resolve_vars_if_possible(sup_type);
- let outlives =
- &mut TypeOutlives::new(self, self.tcx, &region_bound_pairs, None, param_env);
+ let outlives = &mut TypeOutlives::new(
+ self,
+ self.tcx,
+ &outlives_env.region_bound_pairs(),
+ None,
+ outlives_env.param_env,
+ );
let category = origin.to_constraint_category();
outlives.type_must_outlive(origin, sup_type, sub_region, category);
}