Skip to content

Commit dbeda5e

Browse files
nikomatsakisdavidtwco
authored andcommitted
remove the at_location from Locations
We are not currently using it for anything; even polonius just uses the `from_location`.
1 parent 5ddda3f commit dbeda5e

File tree

7 files changed

+20
-86
lines changed

7 files changed

+20
-86
lines changed

src/librustc_mir/borrow_check/nll/constraint_generation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ impl<'cx, 'cg, 'gcx, 'tcx> ConstraintGeneration<'cx, 'cg, 'gcx, 'tcx> {
315315
span,
316316
ref_region.to_region_vid(),
317317
borrow_region.to_region_vid(),
318-
location.successor_within_block(),
319318
);
320319

321320
if let Some(all_facts) = self.all_facts {

src/librustc_mir/borrow_check/nll/constraint_set.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::mir::Location;
1211
use rustc::ty::RegionVid;
1312
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
1413

@@ -24,8 +23,8 @@ crate struct ConstraintSet {
2423
impl ConstraintSet {
2524
pub fn push(&mut self, constraint: OutlivesConstraint) {
2625
debug!(
27-
"add_outlives({:?}: {:?} @ {:?}",
28-
constraint.sup, constraint.sub, constraint.point
26+
"add_outlives({:?}: {:?})",
27+
constraint.sup, constraint.sub
2928
);
3029
if constraint.sup == constraint.sub {
3130
// 'a: 'a is pretty uninteresting
@@ -86,9 +85,6 @@ pub struct OutlivesConstraint {
8685
/// Region that must be outlived.
8786
pub sub: RegionVid,
8887

89-
/// At this location.
90-
pub point: Location,
91-
9288
/// Later on, we thread the constraints onto a linked list
9389
/// grouped by their `sub` field. So if you had:
9490
///
@@ -107,8 +103,8 @@ impl fmt::Debug for OutlivesConstraint {
107103
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
108104
write!(
109105
formatter,
110-
"({:?}: {:?} @ {:?}) due to {:?}",
111-
self.sup, self.sub, self.point, self.span
106+
"({:?}: {:?}) due to {:?}",
107+
self.sup, self.sub, self.span
112108
)
113109
}
114110
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
8282
let OutlivesConstraint {
8383
sup,
8484
sub,
85-
point,
8685
span,
8786
next: _,
8887
} = constraint;
8988
with_msg(&format!(
90-
"{:?}: {:?} @ {:?} due to {:?}",
89+
"{:?}: {:?} due to {:?}",
9190
sup,
9291
sub,
93-
point,
9492
span
9593
))?;
9694
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'this, 'tcx> dot::Labeller<'this> for RegionInferenceContext<'tcx> {
4444
dot::LabelText::LabelStr(format!("{:?}", n).into_cow())
4545
}
4646
fn edge_label(&'this self, e: &OutlivesConstraint) -> dot::LabelText<'this> {
47-
dot::LabelText::LabelStr(format!("{:?}", e.point).into_cow())
47+
dot::LabelText::LabelStr(format!("{:?}", e.span).into_cow())
4848
}
4949
}
5050

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
359359
span: Span,
360360
sup: RegionVid,
361361
sub: RegionVid,
362-
point: Location,
363362
) {
364363
assert!(self.inferred_values.is_none(), "values already inferred");
365364
self.constraints.push(OutlivesConstraint {
366365
span,
367366
sup,
368367
sub,
369-
point,
370368
next: None,
371369
})
372370
}
@@ -503,7 +501,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
503501
for type_test in &self.type_tests {
504502
debug!("check_type_test: {:?}", type_test);
505503

506-
if self.eval_region_test(mir, type_test.point, type_test.lower_bound, &type_test.test) {
504+
if self.eval_region_test(mir, type_test.lower_bound, &type_test.test) {
507505
continue;
508506
}
509507

@@ -765,31 +763,30 @@ impl<'tcx> RegionInferenceContext<'tcx> {
765763
fn eval_region_test(
766764
&self,
767765
mir: &Mir<'tcx>,
768-
point: Location,
769766
lower_bound: RegionVid,
770767
test: &RegionTest,
771768
) -> bool {
772769
debug!(
773-
"eval_region_test(point={:?}, lower_bound={:?}, test={:?})",
774-
point, lower_bound, test
770+
"eval_region_test(lower_bound={:?}, test={:?})",
771+
lower_bound, test
775772
);
776773

777774
match test {
778775
RegionTest::IsOutlivedByAllRegionsIn(regions) => regions
779776
.iter()
780-
.all(|&r| self.eval_outlives(mir, r, lower_bound, point)),
777+
.all(|&r| self.eval_outlives(mir, r, lower_bound)),
781778

782779
RegionTest::IsOutlivedByAnyRegionIn(regions) => regions
783780
.iter()
784-
.any(|&r| self.eval_outlives(mir, r, lower_bound, point)),
781+
.any(|&r| self.eval_outlives(mir, r, lower_bound)),
785782

786783
RegionTest::Any(tests) => tests
787784
.iter()
788-
.any(|test| self.eval_region_test(mir, point, lower_bound, test)),
785+
.any(|test| self.eval_region_test(mir, lower_bound, test)),
789786

790787
RegionTest::All(tests) => tests
791788
.iter()
792-
.all(|test| self.eval_region_test(mir, point, lower_bound, test)),
789+
.all(|test| self.eval_region_test(mir, lower_bound, test)),
793790
}
794791
}
795792

@@ -799,11 +796,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
799796
_mir: &Mir<'tcx>,
800797
sup_region: RegionVid,
801798
sub_region: RegionVid,
802-
point: Location,
803799
) -> bool {
804800
debug!(
805-
"eval_outlives({:?}: {:?} @ {:?})",
806-
sup_region, sub_region, point
801+
"eval_outlives({:?}: {:?})",
802+
sup_region, sub_region
807803
);
808804

809805
let inferred_values = self

src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> {
146146
) -> TypeTest<'tcx> {
147147
let lower_bound = self.to_region_vid(region);
148148

149-
let point = self.locations.at_location().unwrap_or(Location::START);
149+
let point = self.locations.from_location().unwrap_or(Location::START);
150150

151151
let test = self.verify_bound_to_region_test(&bound);
152152

@@ -197,13 +197,11 @@ impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> {
197197

198198
fn add_outlives(&mut self, sup: ty::RegionVid, sub: ty::RegionVid) {
199199
let span = self.span();
200-
let point = self.locations.at_location().unwrap_or(Location::START);
201200

202201
self.outlives_constraints.push(OutlivesConstraint {
203202
span,
204203
sub,
205204
sup,
206-
point,
207205
next: None,
208206
});
209207
}

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

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,6 @@ pub enum Locations {
671671
/// This is intended for error reporting and diagnosis; the
672672
/// constraints may *take effect* at a distinct spot.
673673
from_location: Location,
674-
675-
/// The constraints must be met at this location. In terms of the
676-
/// NLL RFC, when you have a constraint `R1: R2 @ P`, this field
677-
/// is the `P` value.
678-
at_location: Location,
679674
},
680675
}
681676

@@ -686,13 +681,6 @@ impl Locations {
686681
Locations::Pair { from_location, .. } => Some(*from_location),
687682
}
688683
}
689-
690-
pub fn at_location(&self) -> Option<Location> {
691-
match self {
692-
Locations::All => None,
693-
Locations::Pair { at_location, .. } => Some(*at_location),
694-
}
695-
}
696684
}
697685

698686
impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
@@ -799,9 +787,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
799787
StatementKind::Assign(ref place, ref rv) => {
800788
let place_ty = place.ty(mir, tcx).to_ty(tcx);
801789
let rv_ty = rv.ty(mir, tcx);
802-
if let Err(terr) =
803-
self.sub_types(rv_ty, place_ty, location.at_successor_within_block())
804-
{
790+
if let Err(terr) = self.sub_types(rv_ty, place_ty, location.at_self()) {
805791
span_mirbug!(
806792
self,
807793
stmt,
@@ -897,15 +883,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
897883
TerminatorKind::DropAndReplace {
898884
ref location,
899885
ref value,
900-
target,
901-
unwind,
886+
target: _,
887+
unwind: _,
902888
} => {
903889
let place_ty = location.ty(mir, tcx).to_ty(tcx);
904890
let rv_ty = value.ty(mir, tcx);
905891

906892
let locations = Locations::Pair {
907893
from_location: term_location,
908-
at_location: target.start_location(),
909894
};
910895
if let Err(terr) = self.sub_types(rv_ty, place_ty, locations) {
911896
span_mirbug!(
@@ -917,26 +902,6 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
917902
terr
918903
);
919904
}
920-
921-
// Subtle: this assignment occurs at the start of
922-
// *both* blocks, so we need to ensure that it holds
923-
// at both locations.
924-
if let Some(unwind) = unwind {
925-
let locations = Locations::Pair {
926-
from_location: term_location,
927-
at_location: unwind.start_location(),
928-
};
929-
if let Err(terr) = self.sub_types(rv_ty, place_ty, locations) {
930-
span_mirbug!(
931-
self,
932-
term,
933-
"bad DropAndReplace ({:?} = {:?}): {:?}",
934-
place_ty,
935-
rv_ty,
936-
terr
937-
);
938-
}
939-
}
940905
}
941906
TerminatorKind::SwitchInt {
942907
ref discr,
@@ -1052,11 +1017,10 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
10521017
) {
10531018
let tcx = self.tcx();
10541019
match *destination {
1055-
Some((ref dest, target_block)) => {
1020+
Some((ref dest, _target_block)) => {
10561021
let dest_ty = dest.ty(mir, tcx).to_ty(tcx);
10571022
let locations = Locations::Pair {
10581023
from_location: term_location,
1059-
at_location: target_block.start_location(),
10601024
};
10611025
if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations) {
10621026
span_mirbug!(
@@ -1674,29 +1638,12 @@ trait AtLocation {
16741638
/// indicated by `self`. This is typically used when processing
16751639
/// "inputs" to the given location.
16761640
fn at_self(self) -> Locations;
1677-
1678-
/// Creates a `Locations` where `self` is the from-location and
1679-
/// its successor within the block is the at-location. This means
1680-
/// that any required region relationships must hold only upon
1681-
/// **exiting** the statement/terminator indicated by `self`. This
1682-
/// is for example used when you have a `place = rv` statement: it
1683-
/// indicates that the `typeof(rv) <: typeof(place)` as of the
1684-
/// **next** statement.
1685-
fn at_successor_within_block(self) -> Locations;
16861641
}
16871642

16881643
impl AtLocation for Location {
16891644
fn at_self(self) -> Locations {
16901645
Locations::Pair {
16911646
from_location: self,
1692-
at_location: self,
1693-
}
1694-
}
1695-
1696-
fn at_successor_within_block(self) -> Locations {
1697-
Locations::Pair {
1698-
from_location: self,
1699-
at_location: self.successor_within_block(),
17001647
}
17011648
}
17021649
}

0 commit comments

Comments
 (0)