Switched to while let in DFS and deriving Ord on ConstraintCategory.

This commit is contained in:
David Wood 2018-06-20 21:11:27 +01:00
parent fd0806618c
commit 58a723209d
No known key found for this signature in database
GPG key ID: 01760B4F9F53F154
2 changed files with 4 additions and 33 deletions

View file

@ -13,7 +13,6 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use borrow_check::nll::type_check::Locations;
use std::fmt;
use std::cmp::Ordering;
use std::ops::Deref;
#[derive(Clone, Default)]
@ -112,7 +111,7 @@ impl fmt::Debug for OutlivesConstraint {
/// Constraints that are considered interesting can be categorized to
/// determine why they are interesting.
#[derive(Debug, Eq, PartialEq)]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd)]
crate enum ConstraintCategory {
Assignment,
CallArgument,
@ -120,29 +119,4 @@ crate enum ConstraintCategory {
Other,
}
impl Ord for ConstraintCategory {
fn cmp(&self, other: &Self) -> Ordering {
if self == other {
return Ordering::Equal;
}
match (self, other) {
(ConstraintCategory::Assignment, _) => Ordering::Greater,
(_, ConstraintCategory::Assignment) => Ordering::Less,
(ConstraintCategory::CallArgument, _) => Ordering::Greater,
(_, ConstraintCategory::CallArgument) => Ordering::Less,
(ConstraintCategory::Cast, _) => Ordering::Greater,
(_, ConstraintCategory::Cast) => Ordering::Less,
(ConstraintCategory::Other, _) => Ordering::Greater,
}
}
}
impl PartialOrd for ConstraintCategory {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" });

View file

@ -978,20 +978,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// Mapping of regions to the previous region and constraint index that led to it.
let mut previous = FxHashMap();
// Current region in traversal.
let mut current = r0;
// Regions yet to be visited.
let mut next = vec! [ current ];
let mut next = vec! [ r0 ];
// Regions that have been visited.
let mut visited = FxHashSet();
// Ends of paths.
let mut end_regions: Vec<RegionVid> = Vec::new();
// When we've still got points to visit...
while !next.is_empty() {
while let Some(current) = next.pop() {
// ...take the next point...
debug!("find_constraint_paths_from_region: next={:?}", next);
current = next.pop().unwrap(); // Can unwrap here as we know the vector is not empty.
debug!("find_constraint_paths_from_region: current={:?} next={:?}", current, next);
// ...find the edges containing it...
let mut upcoming = Vec::new();