remove the at_location
from Locations
We are not currently using it for anything; even polonius just uses the `from_location`.
This commit is contained in:
parent
5ddda3f195
commit
dbeda5ee29
@ -315,7 +315,6 @@ impl<'cx, 'cg, 'gcx, 'tcx> ConstraintGeneration<'cx, 'cg, 'gcx, 'tcx> {
|
||||
span,
|
||||
ref_region.to_region_vid(),
|
||||
borrow_region.to_region_vid(),
|
||||
location.successor_within_block(),
|
||||
);
|
||||
|
||||
if let Some(all_facts) = self.all_facts {
|
||||
|
@ -8,7 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use rustc::mir::Location;
|
||||
use rustc::ty::RegionVid;
|
||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||
|
||||
@ -24,8 +23,8 @@ crate struct ConstraintSet {
|
||||
impl ConstraintSet {
|
||||
pub fn push(&mut self, constraint: OutlivesConstraint) {
|
||||
debug!(
|
||||
"add_outlives({:?}: {:?} @ {:?}",
|
||||
constraint.sup, constraint.sub, constraint.point
|
||||
"add_outlives({:?}: {:?})",
|
||||
constraint.sup, constraint.sub
|
||||
);
|
||||
if constraint.sup == constraint.sub {
|
||||
// 'a: 'a is pretty uninteresting
|
||||
@ -86,9 +85,6 @@ pub struct OutlivesConstraint {
|
||||
/// Region that must be outlived.
|
||||
pub sub: RegionVid,
|
||||
|
||||
/// At this location.
|
||||
pub point: Location,
|
||||
|
||||
/// Later on, we thread the constraints onto a linked list
|
||||
/// grouped by their `sub` field. So if you had:
|
||||
///
|
||||
@ -107,8 +103,8 @@ impl fmt::Debug for OutlivesConstraint {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
formatter,
|
||||
"({:?}: {:?} @ {:?}) due to {:?}",
|
||||
self.sup, self.sub, self.point, self.span
|
||||
"({:?}: {:?}) due to {:?}",
|
||||
self.sup, self.sub, self.span
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -82,15 +82,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
let OutlivesConstraint {
|
||||
sup,
|
||||
sub,
|
||||
point,
|
||||
span,
|
||||
next: _,
|
||||
} = constraint;
|
||||
with_msg(&format!(
|
||||
"{:?}: {:?} @ {:?} due to {:?}",
|
||||
"{:?}: {:?} due to {:?}",
|
||||
sup,
|
||||
sub,
|
||||
point,
|
||||
span
|
||||
))?;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ impl<'this, 'tcx> dot::Labeller<'this> for RegionInferenceContext<'tcx> {
|
||||
dot::LabelText::LabelStr(format!("{:?}", n).into_cow())
|
||||
}
|
||||
fn edge_label(&'this self, e: &OutlivesConstraint) -> dot::LabelText<'this> {
|
||||
dot::LabelText::LabelStr(format!("{:?}", e.point).into_cow())
|
||||
dot::LabelText::LabelStr(format!("{:?}", e.span).into_cow())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,14 +359,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
span: Span,
|
||||
sup: RegionVid,
|
||||
sub: RegionVid,
|
||||
point: Location,
|
||||
) {
|
||||
assert!(self.inferred_values.is_none(), "values already inferred");
|
||||
self.constraints.push(OutlivesConstraint {
|
||||
span,
|
||||
sup,
|
||||
sub,
|
||||
point,
|
||||
next: None,
|
||||
})
|
||||
}
|
||||
@ -503,7 +501,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
for type_test in &self.type_tests {
|
||||
debug!("check_type_test: {:?}", type_test);
|
||||
|
||||
if self.eval_region_test(mir, type_test.point, type_test.lower_bound, &type_test.test) {
|
||||
if self.eval_region_test(mir, type_test.lower_bound, &type_test.test) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -765,31 +763,30 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
fn eval_region_test(
|
||||
&self,
|
||||
mir: &Mir<'tcx>,
|
||||
point: Location,
|
||||
lower_bound: RegionVid,
|
||||
test: &RegionTest,
|
||||
) -> bool {
|
||||
debug!(
|
||||
"eval_region_test(point={:?}, lower_bound={:?}, test={:?})",
|
||||
point, lower_bound, test
|
||||
"eval_region_test(lower_bound={:?}, test={:?})",
|
||||
lower_bound, test
|
||||
);
|
||||
|
||||
match test {
|
||||
RegionTest::IsOutlivedByAllRegionsIn(regions) => regions
|
||||
.iter()
|
||||
.all(|&r| self.eval_outlives(mir, r, lower_bound, point)),
|
||||
.all(|&r| self.eval_outlives(mir, r, lower_bound)),
|
||||
|
||||
RegionTest::IsOutlivedByAnyRegionIn(regions) => regions
|
||||
.iter()
|
||||
.any(|&r| self.eval_outlives(mir, r, lower_bound, point)),
|
||||
.any(|&r| self.eval_outlives(mir, r, lower_bound)),
|
||||
|
||||
RegionTest::Any(tests) => tests
|
||||
.iter()
|
||||
.any(|test| self.eval_region_test(mir, point, lower_bound, test)),
|
||||
.any(|test| self.eval_region_test(mir, lower_bound, test)),
|
||||
|
||||
RegionTest::All(tests) => tests
|
||||
.iter()
|
||||
.all(|test| self.eval_region_test(mir, point, lower_bound, test)),
|
||||
.all(|test| self.eval_region_test(mir, lower_bound, test)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -799,11 +796,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
_mir: &Mir<'tcx>,
|
||||
sup_region: RegionVid,
|
||||
sub_region: RegionVid,
|
||||
point: Location,
|
||||
) -> bool {
|
||||
debug!(
|
||||
"eval_outlives({:?}: {:?} @ {:?})",
|
||||
sup_region, sub_region, point
|
||||
"eval_outlives({:?}: {:?})",
|
||||
sup_region, sub_region
|
||||
);
|
||||
|
||||
let inferred_values = self
|
||||
|
@ -146,7 +146,7 @@ impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> {
|
||||
) -> TypeTest<'tcx> {
|
||||
let lower_bound = self.to_region_vid(region);
|
||||
|
||||
let point = self.locations.at_location().unwrap_or(Location::START);
|
||||
let point = self.locations.from_location().unwrap_or(Location::START);
|
||||
|
||||
let test = self.verify_bound_to_region_test(&bound);
|
||||
|
||||
@ -197,13 +197,11 @@ impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> {
|
||||
|
||||
fn add_outlives(&mut self, sup: ty::RegionVid, sub: ty::RegionVid) {
|
||||
let span = self.span();
|
||||
let point = self.locations.at_location().unwrap_or(Location::START);
|
||||
|
||||
self.outlives_constraints.push(OutlivesConstraint {
|
||||
span,
|
||||
sub,
|
||||
sup,
|
||||
point,
|
||||
next: None,
|
||||
});
|
||||
}
|
||||
|
@ -671,11 +671,6 @@ pub enum Locations {
|
||||
/// This is intended for error reporting and diagnosis; the
|
||||
/// constraints may *take effect* at a distinct spot.
|
||||
from_location: Location,
|
||||
|
||||
/// The constraints must be met at this location. In terms of the
|
||||
/// NLL RFC, when you have a constraint `R1: R2 @ P`, this field
|
||||
/// is the `P` value.
|
||||
at_location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
@ -686,13 +681,6 @@ impl Locations {
|
||||
Locations::Pair { from_location, .. } => Some(*from_location),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn at_location(&self) -> Option<Location> {
|
||||
match self {
|
||||
Locations::All => None,
|
||||
Locations::Pair { at_location, .. } => Some(*at_location),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
@ -799,9 +787,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
StatementKind::Assign(ref place, ref rv) => {
|
||||
let place_ty = place.ty(mir, tcx).to_ty(tcx);
|
||||
let rv_ty = rv.ty(mir, tcx);
|
||||
if let Err(terr) =
|
||||
self.sub_types(rv_ty, place_ty, location.at_successor_within_block())
|
||||
{
|
||||
if let Err(terr) = self.sub_types(rv_ty, place_ty, location.at_self()) {
|
||||
span_mirbug!(
|
||||
self,
|
||||
stmt,
|
||||
@ -897,15 +883,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
TerminatorKind::DropAndReplace {
|
||||
ref location,
|
||||
ref value,
|
||||
target,
|
||||
unwind,
|
||||
target: _,
|
||||
unwind: _,
|
||||
} => {
|
||||
let place_ty = location.ty(mir, tcx).to_ty(tcx);
|
||||
let rv_ty = value.ty(mir, tcx);
|
||||
|
||||
let locations = Locations::Pair {
|
||||
from_location: term_location,
|
||||
at_location: target.start_location(),
|
||||
};
|
||||
if let Err(terr) = self.sub_types(rv_ty, place_ty, locations) {
|
||||
span_mirbug!(
|
||||
@ -917,26 +902,6 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
terr
|
||||
);
|
||||
}
|
||||
|
||||
// Subtle: this assignment occurs at the start of
|
||||
// *both* blocks, so we need to ensure that it holds
|
||||
// at both locations.
|
||||
if let Some(unwind) = unwind {
|
||||
let locations = Locations::Pair {
|
||||
from_location: term_location,
|
||||
at_location: unwind.start_location(),
|
||||
};
|
||||
if let Err(terr) = self.sub_types(rv_ty, place_ty, locations) {
|
||||
span_mirbug!(
|
||||
self,
|
||||
term,
|
||||
"bad DropAndReplace ({:?} = {:?}): {:?}",
|
||||
place_ty,
|
||||
rv_ty,
|
||||
terr
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
TerminatorKind::SwitchInt {
|
||||
ref discr,
|
||||
@ -1052,11 +1017,10 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
|
||||
) {
|
||||
let tcx = self.tcx();
|
||||
match *destination {
|
||||
Some((ref dest, target_block)) => {
|
||||
Some((ref dest, _target_block)) => {
|
||||
let dest_ty = dest.ty(mir, tcx).to_ty(tcx);
|
||||
let locations = Locations::Pair {
|
||||
from_location: term_location,
|
||||
at_location: target_block.start_location(),
|
||||
};
|
||||
if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations) {
|
||||
span_mirbug!(
|
||||
@ -1674,29 +1638,12 @@ trait AtLocation {
|
||||
/// indicated by `self`. This is typically used when processing
|
||||
/// "inputs" to the given location.
|
||||
fn at_self(self) -> Locations;
|
||||
|
||||
/// Creates a `Locations` where `self` is the from-location and
|
||||
/// its successor within the block is the at-location. This means
|
||||
/// that any required region relationships must hold only upon
|
||||
/// **exiting** the statement/terminator indicated by `self`. This
|
||||
/// is for example used when you have a `place = rv` statement: it
|
||||
/// indicates that the `typeof(rv) <: typeof(place)` as of the
|
||||
/// **next** statement.
|
||||
fn at_successor_within_block(self) -> Locations;
|
||||
}
|
||||
|
||||
impl AtLocation for Location {
|
||||
fn at_self(self) -> Locations {
|
||||
Locations::Pair {
|
||||
from_location: self,
|
||||
at_location: self,
|
||||
}
|
||||
}
|
||||
|
||||
fn at_successor_within_block(self) -> Locations {
|
||||
Locations::Pair {
|
||||
from_location: self,
|
||||
at_location: self.successor_within_block(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user