Skip to content

Commit ad71cbf

Browse files
committed
use deref instead of inner
1 parent 4b44db1 commit ad71cbf

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/librustc_mir/borrow_check/nll/constraint_set.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
1515

1616
use std::fmt;
1717
use syntax_pos::Span;
18+
use std::ops::Deref;
1819

1920
#[derive(Clone, Default)]
2021
crate struct ConstraintSet {
@@ -37,10 +38,6 @@ impl ConstraintSet {
3738
}
3839
}
3940

40-
pub fn inner(&self) -> &IndexVec<ConstraintIndex, OutlivesConstraint> {
41-
&self.constraints
42-
}
43-
4441
pub fn link(&mut self, len: usize) -> IndexVec<RegionVid, Option<ConstraintIndex>> {
4542
let mut map = IndexVec::from_elem_n(None, len);
4643

@@ -66,6 +63,12 @@ impl ConstraintSet {
6663
}
6764
}
6865

66+
impl Deref for ConstraintSet {
67+
type Target = IndexVec<ConstraintIndex, OutlivesConstraint>;
68+
69+
fn deref(&self) -> &Self::Target { &self.constraints }
70+
}
71+
6972
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
7073
pub struct OutlivesConstraint {
7174
// NB. The ordering here is not significant for correctness, but

src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
7676
}
7777
}
7878

79-
let mut constraints: Vec<_> = self.constraints.inner().iter().collect();
79+
let mut constraints: Vec<_> = self.constraints.iter().collect();
8080
constraints.sort();
8181
for constraint in &constraints {
8282
let OutlivesConstraint {

src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'this, 'tcx> dot::GraphWalk<'this> for RegionInferenceContext<'tcx> {
5757
vids.into_cow()
5858
}
5959
fn edges(&'this self) -> dot::Edges<'this, OutlivesConstraint> {
60-
(&self.constraints.inner().raw[..]).into_cow()
60+
(&self.constraints.raw[..]).into_cow()
6161
}
6262

6363
// Render `a: b` as `a <- b`, indicating the flow

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
216216
type_tests: Vec<TypeTest<'tcx>>,
217217
) -> Self {
218218
// The `next` field should not yet have been initialized:
219-
debug_assert!(outlives_constraints.inner().iter().all(|c| c.next.is_none()));
219+
debug_assert!(outlives_constraints.iter().all(|c| c.next.is_none()));
220220

221221
let num_region_variables = var_infos.len();
222222
let num_universal_regions = universal_regions.len();
@@ -438,7 +438,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
438438
fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
439439
debug!("compute_region_values()");
440440
debug!("compute_region_values: constraints={:#?}", {
441-
let mut constraints: Vec<_> = self.constraints.inner().iter().collect();
441+
let mut constraints: Vec<_> = self.constraints.iter().collect();
442442
constraints.sort();
443443
constraints
444444
});
@@ -450,7 +450,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
450450
let dependency_map = self.dependency_map.as_ref().unwrap();
451451

452452
// Constraints that may need to be repropagated (initially all):
453-
let mut dirty_list: Vec<_> = self.constraints.inner().indices().collect();
453+
let mut dirty_list: Vec<_> = self.constraints.indices().collect();
454454

455455
// Set to 0 for each constraint that is on the dirty list:
456456
let mut clean_bit_vec = BitVector::new(dirty_list.len());
@@ -459,7 +459,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
459459
while let Some(constraint_idx) = dirty_list.pop() {
460460
clean_bit_vec.insert(constraint_idx.index());
461461

462-
let constraint = &self.constraints.inner()[constraint_idx];
462+
let constraint = &self.constraints[constraint_idx];
463463
debug!("propagate_constraints: constraint={:?}", constraint);
464464

465465
if inferred_values.add_region(constraint.sup, constraint.sub) {
@@ -925,7 +925,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
925925
);
926926

927927
let blame_index = self.blame_constraint(longer_fr, shorter_fr);
928-
let blame_span = self.constraints.inner()[blame_index].span;
928+
let blame_span = self.constraints[blame_index].span;
929929

930930
if let Some(propagated_outlives_requirements) = propagated_outlives_requirements {
931931
// Shrink `fr` until we find a non-local region (if we do).
@@ -1016,7 +1016,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10161016
// - `fr1: X` transitively
10171017
// - and `Y` is live at `elem`
10181018
let index = self.blame_constraint(fr1, elem);
1019-
let region_sub = self.constraints.inner()[index].sub;
1019+
let region_sub = self.constraints[index].sub;
10201020

10211021
// then return why `Y` was live at `elem`
10221022
self.liveness_constraints.cause(region_sub, elem)
@@ -1037,7 +1037,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10371037
// of dependencies, which doesn't account for the locations of
10381038
// contraints at all. But it will do for now.
10391039
let relevant_constraint = self.constraints
1040-
.inner()
10411040
.iter_enumerated()
10421041
.filter_map(|(i, constraint)| {
10431042
if !self.liveness_constraints.contains(constraint.sub, elem) {
@@ -1073,7 +1072,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10731072

10741073
while changed {
10751074
changed = false;
1076-
for constraint in self.constraints.inner() {
1075+
for constraint in self.constraints.iter() {
10771076
if let Some(n) = result_set[constraint.sup] {
10781077
let m = n + 1;
10791078
if result_set[constraint.sub]

0 commit comments

Comments
 (0)