From e995a91a314da7df85f5471cbc621874b5d42b53 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Tue, 3 Apr 2018 08:45:06 +0900 Subject: [PATCH] Better Option handling --- src/librustc/dep_graph/dep_node.rs | 7 ++----- src/librustc/dep_graph/graph.rs | 7 ++++++- src/librustc/hir/pat_util.rs | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 78e57c6a5d78f..14a818ddafb71 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -334,11 +334,8 @@ macro_rules! define_dep_nodes { pub fn extract_def_id(&self, tcx: TyCtxt) -> Option { 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 } diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 1721d1dd0e9c5..e308f2924a05c 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -489,7 +489,12 @@ impl DepGraph { } pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option { - 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) { diff --git a/src/librustc/hir/pat_util.rs b/src/librustc/hir/pat_util.rs index 14989f1ff7d8a..8a714a5fbd847 100644 --- a/src/librustc/hir/pat_util.rs +++ b/src/librustc/hir/pat_util.rs @@ -47,7 +47,7 @@ impl 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, } }