diff --git a/src/librustc_mir/borrow_check/nll/constraint_set.rs b/src/librustc_mir/borrow_check/nll/constraint_set.rs index 232242b552f7..d8c26960a721 100644 --- a/src/librustc_mir/borrow_check/nll/constraint_set.rs +++ b/src/librustc_mir/borrow_check/nll/constraint_set.rs @@ -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 { - Some(self.cmp(other)) - } -} - - newtype_index!(ConstraintIndex { DEBUG_FORMAT = "ConstraintIndex({})" }); diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index 713ff7002b32..d7e818c50437 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -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 = 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();