Skip to content

Commit

Permalink
Better Option handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Jul 27, 2018
1 parent 1bc49a9 commit e995a91
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/librustc/dep_graph/dep_node.rs
Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion src/librustc/dep_graph/graph.rs
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/pat_util.rs
Expand Up @@ -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,
}
}
Expand Down

0 comments on commit e995a91

Please sign in to comment.