Skip to content

Commit

Permalink
region obligations, remove body_id
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Jul 4, 2022
1 parent a0d2d9f commit 9f95c60
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
});
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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>,

Expand All @@ -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
}

Expand Down
21 changes: 6 additions & 15 deletions compiler/rustc_infer/src/infer/outlives/obligations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand All @@ -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)
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down

0 comments on commit 9f95c60

Please sign in to comment.