region obligations, remove body_id

This commit is contained in:
lcnr 2022-06-29 18:14:11 +02:00
parent a0d2d9f315
commit 9f95c605f8
4 changed files with 10 additions and 20 deletions

View File

@ -128,7 +128,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
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)),
region_obligations.iter().map(|r_o| (r_o.sup_type, r_o.sub_region)),
region_constraints,
)
});

View File

@ -15,7 +15,6 @@ use rustc_data_structures::sync::Lrc;
use rustc_data_structures::undo_log::Rollback;
use rustc_data_structures::unify as ut;
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
@ -147,7 +146,7 @@ pub struct InferCtxtInner<'tcx> {
/// for each body-id in this map, which will process the
/// obligations within. This is expected to be done 'late enough'
/// that all type inference variables have been bound and so forth.
region_obligations: Vec<(hir::HirId, RegionObligation<'tcx>)>,
region_obligations: Vec<RegionObligation<'tcx>>,
undo_log: InferCtxtUndoLogs<'tcx>,
@ -171,7 +170,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
}
#[inline]
pub fn region_obligations(&self) -> &[(hir::HirId, RegionObligation<'tcx>)] {
pub fn region_obligations(&self) -> &[RegionObligation<'tcx>] {
&self.region_obligations
}

View File

@ -68,7 +68,6 @@ use crate::infer::{
};
use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_data_structures::undo_log::UndoLogs;
use rustc_hir as hir;
use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, Region, Ty, TyCtxt, TypeFoldable};
use smallvec::smallvec;
@ -79,16 +78,11 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
/// and later processed by regionck, when full type information is
/// available (see `region_obligations` field for more
/// information).
pub fn register_region_obligation(
&self,
body_id: hir::HirId,
obligation: RegionObligation<'tcx>,
) {
debug!("register_region_obligation(body_id={:?}, obligation={:?})", body_id, obligation);
#[instrument(level = "debug", skip(self))]
pub fn register_region_obligation(&self, obligation: RegionObligation<'tcx>) {
let mut inner = self.inner.borrow_mut();
inner.undo_log.push(UndoLog::PushRegionObligation);
inner.region_obligations.push((body_id, obligation));
inner.region_obligations.push(obligation);
}
pub fn register_region_obligation_with_cause(
@ -108,14 +102,11 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
)
});
self.register_region_obligation(
cause.body_id,
RegionObligation { sup_type, sub_region, origin },
);
self.register_region_obligation(RegionObligation { sup_type, sub_region, origin });
}
/// Trait queries just want to pass back type obligations "as is"
pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionObligation<'tcx>)> {
pub fn take_registered_region_obligations(&self) -> Vec<RegionObligation<'tcx>> {
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
}
@ -156,7 +147,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
let my_region_obligations = self.take_registered_region_obligations();
for (_body_id, RegionObligation { sup_type, sub_region, origin }) in my_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

View File

@ -95,7 +95,7 @@ pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
infcx.tcx,
region_obligations
.iter()
.map(|(_, r_o)| (r_o.sup_type, r_o.sub_region))
.map(|r_o| (r_o.sup_type, r_o.sub_region))
.map(|(ty, r)| (infcx.resolve_vars_if_possible(ty), r)),
&region_constraint_data,
);