Skip to content

Commit 9792cf0

Browse files
committed
remove non-borrowck member constraints
1 parent 674c657 commit 9792cf0

File tree

12 files changed

+25
-436
lines changed

12 files changed

+25
-436
lines changed

Diff for: compiler/rustc_borrowck/src/member_constraints.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ where
2222
/// Stores the data about each `R0 member of [R1..Rn]` constraint.
2323
/// These are organized into a linked list, so each constraint
2424
/// contains the index of the next constraint with the same `R0`.
25-
constraints: IndexVec<NllMemberConstraintIndex, NllMemberConstraint<'tcx>>,
25+
constraints: IndexVec<NllMemberConstraintIndex, MemberConstraint<'tcx>>,
2626

2727
/// Stores the `R1..Rn` regions for *all* sets. For any given
2828
/// constraint, we keep two indices so that we can pull out a
@@ -32,7 +32,7 @@ where
3232

3333
/// Represents a `R0 member of [R1..Rn]` constraint
3434
#[derive(Debug)]
35-
pub(crate) struct NllMemberConstraint<'tcx> {
35+
pub(crate) struct MemberConstraint<'tcx> {
3636
next_constraint: Option<NllMemberConstraintIndex>,
3737

3838
/// The span where the hidden type was instantiated.
@@ -87,7 +87,7 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
8787
let start_index = self.choice_regions.len();
8888
self.choice_regions.extend(choice_regions);
8989
let end_index = self.choice_regions.len();
90-
let constraint_index = self.constraints.push(NllMemberConstraint {
90+
let constraint_index = self.constraints.push(MemberConstraint {
9191
next_constraint,
9292
member_region_vid,
9393
definition_span,
@@ -98,14 +98,6 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
9898
});
9999
self.first_constraints.insert(member_region_vid, constraint_index);
100100
}
101-
102-
// TODO: removed in the next commit
103-
pub(crate) fn push_constraint(
104-
&mut self,
105-
_: &rustc_middle::infer::MemberConstraint<'tcx>,
106-
_: impl FnMut(ty::Region<'tcx>) -> ty::RegionVid,
107-
) {
108-
}
109101
}
110102

111103
impl<'tcx, R1> MemberConstraintSet<'tcx, R1>
@@ -186,7 +178,7 @@ where
186178
/// R0 member of [R1..Rn]
187179
/// ```
188180
pub(crate) fn choice_regions(&self, pci: NllMemberConstraintIndex) -> &[ty::RegionVid] {
189-
let NllMemberConstraint { start_index, end_index, .. } = &self.constraints[pci];
181+
let MemberConstraint { start_index, end_index, .. } = &self.constraints[pci];
190182
&self.choice_regions[*start_index..*end_index]
191183
}
192184
}
@@ -195,9 +187,9 @@ impl<'tcx, R> Index<NllMemberConstraintIndex> for MemberConstraintSet<'tcx, R>
195187
where
196188
R: Copy + Eq,
197189
{
198-
type Output = NllMemberConstraint<'tcx>;
190+
type Output = MemberConstraint<'tcx>;
199191

200-
fn index(&self, i: NllMemberConstraintIndex) -> &NllMemberConstraint<'tcx> {
192+
fn index(&self, i: NllMemberConstraintIndex) -> &MemberConstraint<'tcx> {
201193
&self.constraints[i]
202194
}
203195
}
@@ -219,7 +211,7 @@ where
219211
/// target_list: A -> B -> C -> D -> E -> F -> (None)
220212
/// ```
221213
fn append_list(
222-
constraints: &mut IndexSlice<NllMemberConstraintIndex, NllMemberConstraint<'_>>,
214+
constraints: &mut IndexSlice<NllMemberConstraintIndex, MemberConstraint<'_>>,
223215
target_list: NllMemberConstraintIndex,
224216
source_list: NllMemberConstraintIndex,
225217
) {

Diff for: compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

+3-18
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
7777

7878
#[instrument(skip(self), level = "debug")]
7979
pub(super) fn convert_all(&mut self, query_constraints: &QueryRegionConstraints<'tcx>) {
80-
let QueryRegionConstraints { outlives, member_constraints } = query_constraints;
81-
82-
// Annoying: to invoke `self.to_region_vid`, we need access to
83-
// `self.constraints`, but we also want to be mutating
84-
// `self.member_constraints`. For now, just swap out the value
85-
// we want and replace at the end.
86-
let mut tmp = std::mem::take(&mut self.constraints.member_constraints);
87-
for member_constraint in member_constraints {
88-
tmp.push_constraint(member_constraint, |r| self.to_region_vid(r));
89-
}
90-
self.constraints.member_constraints = tmp;
80+
let QueryRegionConstraints { outlives } = query_constraints;
9181

9282
for &(predicate, constraint_category) in outlives {
9383
self.convert(predicate, constraint_category);
@@ -295,13 +285,8 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
295285

296286
match result {
297287
Ok(TypeOpOutput { output: ty, constraints, .. }) => {
298-
if let Some(constraints) = constraints {
299-
assert!(
300-
constraints.member_constraints.is_empty(),
301-
"no member constraints expected from normalizing: {:#?}",
302-
constraints.member_constraints
303-
);
304-
next_outlives_predicates.extend(constraints.outlives.iter().copied());
288+
if let Some(QueryRegionConstraints { outlives }) = constraints {
289+
next_outlives_predicates.extend(outlives.iter().copied());
305290
}
306291
ty
307292
}

Diff for: compiler/rustc_borrowck/src/universal_regions.rs

+4
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,10 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
880880
/// reference those regions from the `ParamEnv`. It is also used
881881
/// during initialization. Relies on the `indices` map having been
882882
/// fully initialized.
883+
///
884+
/// Panics if `r` is not a registered universal region, most notably
885+
/// if it is a placeholder. Handling placeholders requires access to the
886+
/// `MirTypeckRegionConstraints`.
883887
fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid {
884888
if let ty::ReVar(..) = *r {
885889
r.as_var()

Diff for: compiler/rustc_infer/src/infer/canonical/query_response.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,6 @@ impl<'tcx> InferCtxt<'tcx> {
316316
}),
317317
);
318318

319-
// ...also include the query member constraints.
320-
output_query_region_constraints.member_constraints.extend(
321-
query_response
322-
.value
323-
.region_constraints
324-
.member_constraints
325-
.iter()
326-
.map(|p_c| instantiate_value(self.tcx, &result_args, p_c.clone())),
327-
);
328-
329319
let user_result: R =
330320
query_response.instantiate_projected(self.tcx, &result_args, |q_r| q_r.value.clone());
331321

@@ -643,7 +633,7 @@ pub fn make_query_region_constraints<'tcx>(
643633
outlives_obligations: impl Iterator<Item = (Ty<'tcx>, ty::Region<'tcx>, ConstraintCategory<'tcx>)>,
644634
region_constraints: &RegionConstraintData<'tcx>,
645635
) -> QueryRegionConstraints<'tcx> {
646-
let RegionConstraintData { constraints, verifys, member_constraints } = region_constraints;
636+
let RegionConstraintData { constraints, verifys } = region_constraints;
647637

648638
assert!(verifys.is_empty());
649639

@@ -674,5 +664,5 @@ pub fn make_query_region_constraints<'tcx>(
674664
}))
675665
.collect();
676666

677-
QueryRegionConstraints { outlives, member_constraints: member_constraints.clone() }
667+
QueryRegionConstraints { outlives }
678668
}

Diff for: compiler/rustc_infer/src/infer/mod.rs

-21
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub use relate::StructurallyRelateAliases;
1717
pub use relate::combine::PredicateEmittingRelation;
1818
use rustc_data_structures::captures::Captures;
1919
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
20-
use rustc_data_structures::sync::Lrc;
2120
use rustc_data_structures::undo_log::{Rollback, UndoLogs};
2221
use rustc_data_structures::unify as ut;
2322
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
@@ -685,26 +684,6 @@ impl<'tcx> InferCtxt<'tcx> {
685684
self.inner.borrow_mut().unwrap_region_constraints().make_subregion(origin, a, b);
686685
}
687686

688-
/// Require that the region `r` be equal to one of the regions in
689-
/// the set `regions`.
690-
#[instrument(skip(self), level = "debug")]
691-
pub fn add_member_constraint(
692-
&self,
693-
key: ty::OpaqueTypeKey<'tcx>,
694-
definition_span: Span,
695-
hidden_ty: Ty<'tcx>,
696-
region: ty::Region<'tcx>,
697-
in_regions: Lrc<Vec<ty::Region<'tcx>>>,
698-
) {
699-
self.inner.borrow_mut().unwrap_region_constraints().add_member_constraint(
700-
key,
701-
definition_span,
702-
hidden_ty,
703-
region,
704-
in_regions,
705-
);
706-
}
707-
708687
/// Processes a `Coerce` predicate from the fulfillment context.
709688
/// This is NOT the preferred way to handle coercion, which is to
710689
/// invoke `FnCtxt::coerce` or a similar method (see `coercion.rs`).

0 commit comments

Comments
 (0)