rename Constraint to OutlivesConstraint
This commit is contained in:
parent
9980415fbd
commit
ba6a7f7500
3 changed files with 13 additions and 12 deletions
|
|
@ -14,7 +14,7 @@
|
|||
//! context internal state.
|
||||
|
||||
use std::io::{self, Write};
|
||||
use super::{Constraint, RegionInferenceContext};
|
||||
use super::{OutlivesConstraint, RegionInferenceContext};
|
||||
|
||||
// Room for "'_#NNNNr" before things get misaligned.
|
||||
// Easy enough to fix if this ever doesn't seem like
|
||||
|
|
@ -79,7 +79,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
let mut constraints: Vec<_> = self.constraints.iter().collect();
|
||||
constraints.sort();
|
||||
for constraint in &constraints {
|
||||
let Constraint {
|
||||
let OutlivesConstraint {
|
||||
sup,
|
||||
sub,
|
||||
point,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
impl<'this, 'tcx> dot::Labeller<'this> for RegionInferenceContext<'tcx> {
|
||||
type Node = RegionVid;
|
||||
type Edge = Constraint;
|
||||
type Edge = OutlivesConstraint;
|
||||
|
||||
fn graph_id(&'this self) -> dot::Id<'this> {
|
||||
dot::Id::new(format!("RegionInferenceContext")).unwrap()
|
||||
|
|
@ -41,31 +41,31 @@ impl<'this, 'tcx> dot::Labeller<'this> for RegionInferenceContext<'tcx> {
|
|||
fn node_label(&'this self, n: &RegionVid) -> dot::LabelText<'this> {
|
||||
dot::LabelText::LabelStr(format!("{:?}", n).into_cow())
|
||||
}
|
||||
fn edge_label(&'this self, e: &Constraint) -> dot::LabelText<'this> {
|
||||
fn edge_label(&'this self, e: &OutlivesConstraint) -> dot::LabelText<'this> {
|
||||
dot::LabelText::LabelStr(format!("{:?}", e.point).into_cow())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'this, 'tcx> dot::GraphWalk<'this> for RegionInferenceContext<'tcx> {
|
||||
type Node = RegionVid;
|
||||
type Edge = Constraint;
|
||||
type Edge = OutlivesConstraint;
|
||||
|
||||
fn nodes(&'this self) -> dot::Nodes<'this, RegionVid> {
|
||||
let vids: Vec<RegionVid> = self.definitions.indices().collect();
|
||||
vids.into_cow()
|
||||
}
|
||||
fn edges(&'this self) -> dot::Edges<'this, Constraint> {
|
||||
fn edges(&'this self) -> dot::Edges<'this, OutlivesConstraint> {
|
||||
(&self.constraints.raw[..]).into_cow()
|
||||
}
|
||||
|
||||
// Render `a: b` as `a <- b`, indicating the flow
|
||||
// of data during inference.
|
||||
|
||||
fn source(&'this self, edge: &Constraint) -> RegionVid {
|
||||
fn source(&'this self, edge: &OutlivesConstraint) -> RegionVid {
|
||||
edge.sub
|
||||
}
|
||||
|
||||
fn target(&'this self, edge: &Constraint) -> RegionVid {
|
||||
fn target(&'this self, edge: &OutlivesConstraint) -> RegionVid {
|
||||
edge.sup
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ pub struct RegionInferenceContext<'tcx> {
|
|||
dependency_map: Option<IndexVec<RegionVid, Option<ConstraintIndex>>>,
|
||||
|
||||
/// The constraints we have accumulated and used during solving.
|
||||
constraints: IndexVec<ConstraintIndex, Constraint>,
|
||||
constraints: IndexVec<ConstraintIndex, OutlivesConstraint>,
|
||||
|
||||
/// Type constraints that we check after solving.
|
||||
type_tests: Vec<TypeTest<'tcx>>,
|
||||
|
|
@ -118,11 +118,12 @@ pub(crate) enum Cause {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Constraint {
|
||||
pub struct OutlivesConstraint {
|
||||
// NB. The ordering here is not significant for correctness, but
|
||||
// it is for convenience. Before we dump the constraints in the
|
||||
// debugging logs, we sort them, and we'd like the "super region"
|
||||
// to be first, etc. (In particular, span should remain last.)
|
||||
|
||||
/// The region SUP must outlive SUB...
|
||||
sup: RegionVid,
|
||||
|
||||
|
|
@ -387,7 +388,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
) {
|
||||
debug!("add_outlives({:?}: {:?} @ {:?}", sup, sub, point);
|
||||
assert!(self.inferred_values.is_none(), "values already inferred");
|
||||
self.constraints.push(Constraint {
|
||||
self.constraints.push(OutlivesConstraint {
|
||||
span,
|
||||
sup,
|
||||
sub,
|
||||
|
|
@ -1139,7 +1140,7 @@ impl<'tcx> RegionDefinition<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Constraint {
|
||||
impl fmt::Debug for OutlivesConstraint {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
formatter,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue