Skip to content

Commit

Permalink
Rollup merge of rust-lang#51203 - nnethercote:obligations-2, r=michae…
Browse files Browse the repository at this point in the history
…lwoerister

Two minor `obligation_forest` tweaks.

Pretty minimal improvements, but improvements nonetheless.
  • Loading branch information
kennytm committed May 30, 2018
2 parents 874b623 + b43f76e commit 7bf60b7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/librustc_data_structures/obligation_forest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ pub struct ObligationForest<O: ForestObligation> {
done_cache: FxHashSet<O::Predicate>,
/// An cache of the nodes in `nodes`, indexed by predicate.
waiting_cache: FxHashMap<O::Predicate, NodeIndex>,
/// A list of the obligations added in snapshots, to allow
/// for their removal.
cache_list: Vec<O::Predicate>,
scratch: Option<Vec<usize>>,
}

Expand Down Expand Up @@ -158,7 +155,6 @@ impl<O: ForestObligation> ObligationForest<O> {
nodes: vec![],
done_cache: FxHashSet(),
waiting_cache: FxHashMap(),
cache_list: vec![],
scratch: Some(vec![]),
}
}
Expand Down Expand Up @@ -207,7 +203,6 @@ impl<O: ForestObligation> ObligationForest<O> {
debug!("register_obligation_at({:?}, {:?}) - ok, new index is {}",
obligation, parent, self.nodes.len());
v.insert(NodeIndex::new(self.nodes.len()));
self.cache_list.push(obligation.as_predicate().clone());
self.nodes.push(Node::new(parent, obligation));
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_data_structures/obligation_forest/node_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ pub struct NodeIndex {
}

impl NodeIndex {
#[inline]
pub fn new(value: usize) -> NodeIndex {
assert!(value < (u32::MAX as usize));
NodeIndex { index: NonZeroU32::new((value as u32) + 1).unwrap() }
}

#[inline]
pub fn get(self) -> usize {
(self.index.get() - 1) as usize
}
Expand Down

0 comments on commit 7bf60b7

Please sign in to comment.