Skip to content

Commit 9f95c60

Browse files
committed
region obligations, remove body_id
1 parent a0d2d9f commit 9f95c60

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

compiler/rustc_infer/src/infer/canonical/query_response.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
128128
let region_constraints = self.with_region_constraints(|region_constraints| {
129129
make_query_region_constraints(
130130
tcx,
131-
region_obligations.iter().map(|(_, r_o)| (r_o.sup_type, r_o.sub_region)),
131+
region_obligations.iter().map(|r_o| (r_o.sup_type, r_o.sub_region)),
132132
region_constraints,
133133
)
134134
});

compiler/rustc_infer/src/infer/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_data_structures::sync::Lrc;
1515
use rustc_data_structures::undo_log::Rollback;
1616
use rustc_data_structures::unify as ut;
1717
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
18-
use rustc_hir as hir;
1918
use rustc_hir::def_id::{DefId, LocalDefId};
2019
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
2120
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
@@ -147,7 +146,7 @@ pub struct InferCtxtInner<'tcx> {
147146
/// for each body-id in this map, which will process the
148147
/// obligations within. This is expected to be done 'late enough'
149148
/// that all type inference variables have been bound and so forth.
150-
region_obligations: Vec<(hir::HirId, RegionObligation<'tcx>)>,
149+
region_obligations: Vec<RegionObligation<'tcx>>,
151150

152151
undo_log: InferCtxtUndoLogs<'tcx>,
153152

@@ -171,7 +170,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
171170
}
172171

173172
#[inline]
174-
pub fn region_obligations(&self) -> &[(hir::HirId, RegionObligation<'tcx>)] {
173+
pub fn region_obligations(&self) -> &[RegionObligation<'tcx>] {
175174
&self.region_obligations
176175
}
177176

compiler/rustc_infer/src/infer/outlives/obligations.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ use crate::infer::{
6868
};
6969
use crate::traits::{ObligationCause, ObligationCauseCode};
7070
use rustc_data_structures::undo_log::UndoLogs;
71-
use rustc_hir as hir;
7271
use rustc_middle::ty::subst::GenericArgKind;
7372
use rustc_middle::ty::{self, Region, Ty, TyCtxt, TypeFoldable};
7473
use smallvec::smallvec;
@@ -79,16 +78,11 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
7978
/// and later processed by regionck, when full type information is
8079
/// available (see `region_obligations` field for more
8180
/// information).
82-
pub fn register_region_obligation(
83-
&self,
84-
body_id: hir::HirId,
85-
obligation: RegionObligation<'tcx>,
86-
) {
87-
debug!("register_region_obligation(body_id={:?}, obligation={:?})", body_id, obligation);
88-
81+
#[instrument(level = "debug", skip(self))]
82+
pub fn register_region_obligation(&self, obligation: RegionObligation<'tcx>) {
8983
let mut inner = self.inner.borrow_mut();
9084
inner.undo_log.push(UndoLog::PushRegionObligation);
91-
inner.region_obligations.push((body_id, obligation));
85+
inner.region_obligations.push(obligation);
9286
}
9387

9488
pub fn register_region_obligation_with_cause(
@@ -108,14 +102,11 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
108102
)
109103
});
110104

111-
self.register_region_obligation(
112-
cause.body_id,
113-
RegionObligation { sup_type, sub_region, origin },
114-
);
105+
self.register_region_obligation(RegionObligation { sup_type, sub_region, origin });
115106
}
116107

117108
/// Trait queries just want to pass back type obligations "as is"
118-
pub fn take_registered_region_obligations(&self) -> Vec<(hir::HirId, RegionObligation<'tcx>)> {
109+
pub fn take_registered_region_obligations(&self) -> Vec<RegionObligation<'tcx>> {
119110
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
120111
}
121112

@@ -156,7 +147,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
156147

157148
let my_region_obligations = self.take_registered_region_obligations();
158149

159-
for (_body_id, RegionObligation { sup_type, sub_region, origin }) in my_region_obligations {
150+
for RegionObligation { sup_type, sub_region, origin } in my_region_obligations {
160151
debug!(
161152
"process_registered_region_obligations: sup_type={:?} sub_region={:?} origin={:?}",
162153
sup_type, sub_region, origin

compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub fn scrape_region_constraints<'tcx, Op: super::TypeOp<'tcx, Output = R>, R>(
9595
infcx.tcx,
9696
region_obligations
9797
.iter()
98-
.map(|(_, r_o)| (r_o.sup_type, r_o.sub_region))
98+
.map(|r_o| (r_o.sup_type, r_o.sub_region))
9999
.map(|(ty, r)| (infcx.resolve_vars_if_possible(ty), r)),
100100
&region_constraint_data,
101101
);

0 commit comments

Comments
 (0)