Skip to content

Two minor obligation_forest tweaks. #51203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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