Skip to content

Commit e995a91

Browse files
committed
Better Option handling
1 parent 1bc49a9 commit e995a91

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/librustc/dep_graph/dep_node.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,8 @@ macro_rules! define_dep_nodes {
334334
pub fn extract_def_id(&self, tcx: TyCtxt) -> Option<DefId> {
335335
if self.kind.can_reconstruct_query_key() {
336336
let def_path_hash = DefPathHash(self.hash);
337-
if let Some(ref def_path_map) = tcx.def_path_hash_to_def_id.as_ref() {
338-
def_path_map.get(&def_path_hash).cloned()
339-
} else {
340-
None
341-
}
337+
tcx.def_path_hash_to_def_id.as_ref()?
338+
.get(&def_path_hash).cloned()
342339
} else {
343340
None
344341
}

src/librustc/dep_graph/graph.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,12 @@ impl DepGraph {
489489
}
490490

491491
pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
492-
self.data.as_ref().and_then(|t| t.dep_node_debug.borrow().get(&dep_node).cloned())
492+
self.data
493+
.as_ref()?
494+
.dep_node_debug
495+
.borrow()
496+
.get(&dep_node)
497+
.cloned()
493498
}
494499

495500
pub fn edge_deduplication_data(&self) -> (u64, u64) {

src/librustc/hir/pat_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T {
4747
let actual_len = self.len();
4848
EnumerateAndAdjust {
4949
enumerate: self.enumerate(),
50-
gap_pos: if let Some(gap_pos) = gap_pos { gap_pos } else { expected_len },
50+
gap_pos: gap_pos.unwrap_or(expected_len),
5151
gap_len: expected_len - actual_len,
5252
}
5353
}

0 commit comments

Comments
 (0)