Better Option handling

This commit is contained in:
Shotaro Yamada 2018-04-03 08:45:06 +09:00
parent 1bc49a9743
commit e995a91a31
3 changed files with 9 additions and 7 deletions

View file

@ -334,11 +334,8 @@ macro_rules! define_dep_nodes {
pub fn extract_def_id(&self, tcx: TyCtxt) -> Option<DefId> {
if self.kind.can_reconstruct_query_key() {
let def_path_hash = DefPathHash(self.hash);
if let Some(ref def_path_map) = tcx.def_path_hash_to_def_id.as_ref() {
def_path_map.get(&def_path_hash).cloned()
} else {
None
}
tcx.def_path_hash_to_def_id.as_ref()?
.get(&def_path_hash).cloned()
} else {
None
}

View file

@ -489,7 +489,12 @@ impl DepGraph {
}
pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
self.data.as_ref().and_then(|t| t.dep_node_debug.borrow().get(&dep_node).cloned())
self.data
.as_ref()?
.dep_node_debug
.borrow()
.get(&dep_node)
.cloned()
}
pub fn edge_deduplication_data(&self) -> (u64, u64) {

View file

@ -47,7 +47,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
let actual_len = self.len();
EnumerateAndAdjust {
enumerate: self.enumerate(),
gap_pos: if let Some(gap_pos) = gap_pos { gap_pos } else { expected_len },
gap_pos: gap_pos.unwrap_or(expected_len),
gap_len: expected_len - actual_len,
}
}