remove deref impl and add an index impl
The constraint set is going to be more than just a set of outlives constraints.
This commit is contained in:
parent
f673b24ba2
commit
ec560e2c6d
@ -1,11 +1,10 @@
|
||||
use crate::borrow_check::nll::type_check::Locations;
|
||||
use rustc::mir::ConstraintCategory;
|
||||
use rustc::ty::RegionVid;
|
||||
use rustc_data_structures::graph::scc::Sccs;
|
||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||
use crate::borrow_check::nll::type_check::Locations;
|
||||
|
||||
use std::fmt;
|
||||
use std::ops::Deref;
|
||||
use std::ops::Index;
|
||||
|
||||
crate mod graph;
|
||||
|
||||
@ -58,13 +57,17 @@ impl ConstraintSet {
|
||||
let region_graph = &constraint_graph.region_graph(self, static_region);
|
||||
Sccs::new(region_graph)
|
||||
}
|
||||
|
||||
crate fn outlives(&self) -> &IndexVec<OutlivesConstraintIndex, OutlivesConstraint> {
|
||||
&self.outlives
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for ConstraintSet {
|
||||
type Target = IndexVec<OutlivesConstraintIndex, OutlivesConstraint>;
|
||||
impl Index<OutlivesConstraintIndex> for ConstraintSet {
|
||||
type Output = OutlivesConstraint;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.outlives
|
||||
fn index(&self, i: OutlivesConstraintIndex) -> &Self::Output {
|
||||
&self.outlives[i]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let mut constraints: Vec<_> = self.constraints.iter().collect();
|
||||
let mut constraints: Vec<_> = self.constraints.outlives().iter().collect();
|
||||
constraints.sort();
|
||||
for constraint in &constraints {
|
||||
let OutlivesConstraint {
|
||||
|
@ -63,7 +63,7 @@ impl<'a, 'this, 'tcx> dot::GraphWalk<'this> for RawConstraints<'a, 'tcx> {
|
||||
vids.into()
|
||||
}
|
||||
fn edges(&'this self) -> dot::Edges<'this, OutlivesConstraint> {
|
||||
(&self.regioncx.constraints.raw[..]).into()
|
||||
(&self.regioncx.constraints.outlives().raw[..]).into()
|
||||
}
|
||||
|
||||
// Render `a: b` as `a -> b`, indicating the flow
|
||||
|
@ -472,7 +472,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
debug!("propagate_constraints()");
|
||||
|
||||
debug!("propagate_constraints: constraints={:#?}", {
|
||||
let mut constraints: Vec<_> = self.constraints.iter().collect();
|
||||
let mut constraints: Vec<_> = self.constraints.outlives().iter().collect();
|
||||
constraints.sort();
|
||||
constraints
|
||||
.into_iter()
|
||||
|
@ -215,7 +215,7 @@ fn translate_outlives_facts(cx: &mut BorrowCheckContext<'_, '_>) {
|
||||
let location_table = cx.location_table;
|
||||
facts
|
||||
.outlives
|
||||
.extend(cx.constraints.outlives_constraints.iter().flat_map(
|
||||
.extend(cx.constraints.outlives_constraints.outlives().iter().flat_map(
|
||||
|constraint: &OutlivesConstraint| {
|
||||
if let Some(from_location) = constraint.locations.from_location() {
|
||||
Either::Left(iter::once((
|
||||
@ -582,7 +582,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
|
||||
);
|
||||
|
||||
let locations = location.to_locations();
|
||||
for constraint in constraints.iter() {
|
||||
for constraint in constraints.outlives().iter() {
|
||||
let mut constraint = *constraint;
|
||||
constraint.locations = locations;
|
||||
if let ConstraintCategory::Return
|
||||
|
Loading…
x
Reference in New Issue
Block a user