move related types into the new module
This commit is contained in:
parent
e4f03682df
commit
e2c0378a63
@ -1,7 +1,10 @@
|
||||
use borrow_check::nll::region_infer::{ConstraintIndex, OutlivesConstraint};
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc::ty::RegionVid;
|
||||
use rustc::mir::Location;
|
||||
|
||||
use std::fmt;
|
||||
use syntax_pos::Span;
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
crate struct ConstraintSet {
|
||||
@ -31,3 +34,50 @@ impl ConstraintSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
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...
|
||||
pub sup: RegionVid,
|
||||
|
||||
/// 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:
|
||||
///
|
||||
/// Index | Constraint | Next Field
|
||||
/// ----- | ---------- | ----------
|
||||
/// 0 | `'a: 'b` | Some(2)
|
||||
/// 1 | `'b: 'c` | None
|
||||
/// 2 | `'c: 'b` | None
|
||||
pub next: Option<ConstraintIndex>,
|
||||
|
||||
/// Where did this constraint arise?
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl OutlivesConstraint {
|
||||
pub fn dedup_key(&self) -> (RegionVid, RegionVid) {
|
||||
(self.sup, self.sub)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });
|
||||
|
||||
|
@ -17,6 +17,8 @@ use rustc_data_structures::indexed_vec::Idx;
|
||||
use std::borrow::Cow;
|
||||
use std::io::{self, Write};
|
||||
use super::*;
|
||||
use borrow_check::nll::constraint_set::OutlivesConstraint;
|
||||
|
||||
|
||||
impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// Write out the region constraint graph.
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
use super::universal_regions::UniversalRegions;
|
||||
use borrow_check::nll::region_infer::values::ToElementIndex;
|
||||
use borrow_check::nll::constraint_set::ConstraintSet;
|
||||
use borrow_check::nll::constraint_set::{ConstraintIndex, ConstraintSet, OutlivesConstraint};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::infer::canonical::QueryRegionConstraint;
|
||||
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
@ -26,7 +26,6 @@ use rustc::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc::util::common::{self, ErrorReported};
|
||||
use rustc_data_structures::bitvec::BitVector;
|
||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use syntax_pos::Span;
|
||||
|
||||
@ -115,43 +114,6 @@ pub(crate) enum Cause {
|
||||
UniversalRegion(RegionVid),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
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...
|
||||
pub sup: RegionVid,
|
||||
|
||||
/// 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:
|
||||
///
|
||||
/// Index | Constraint | Next Field
|
||||
/// ----- | ---------- | ----------
|
||||
/// 0 | `'a: 'b` | Some(2)
|
||||
/// 1 | `'b: 'c` | None
|
||||
/// 2 | `'c: 'b` | None
|
||||
pub next: Option<ConstraintIndex>,
|
||||
|
||||
/// Where did this constraint arise?
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl OutlivesConstraint {
|
||||
pub fn dedup_key(&self) -> (RegionVid, RegionVid) {
|
||||
(self.sup, self.sub)
|
||||
}
|
||||
}
|
||||
|
||||
newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });
|
||||
|
||||
/// A "type test" corresponds to an outlives constraint between a type
|
||||
/// and a lifetime, like `T: 'x` or `<T as Foo>::Bar: 'x`. They are
|
||||
/// translated from the `Verify` region constraints in the ordinary
|
||||
@ -1153,16 +1115,6 @@ impl<'tcx> RegionDefinition<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ClosureRegionRequirementsExt<'gcx, 'tcx> {
|
||||
fn apply_requirements(
|
||||
&self,
|
||||
|
@ -9,8 +9,9 @@
|
||||
// except according to those terms.
|
||||
|
||||
use borrow_check::location::LocationTable;
|
||||
use borrow_check::nll::constraint_set::OutlivesConstraint;
|
||||
use borrow_check::nll::facts::AllFacts;
|
||||
use borrow_check::nll::region_infer::{OutlivesConstraint, RegionTest, TypeTest};
|
||||
use borrow_check::nll::region_infer::{RegionTest, TypeTest};
|
||||
use borrow_check::nll::type_check::Locations;
|
||||
use borrow_check::nll::universal_regions::UniversalRegions;
|
||||
use borrow_check::nll::constraint_set::ConstraintSet;
|
||||
|
Loading…
x
Reference in New Issue
Block a user