]> git.lizzy.rs Git - rust.git/commitdiff
Better Option handling
authorShotaro Yamada <sinkuu@sinkuu.xyz>
Mon, 2 Apr 2018 23:45:06 +0000 (08:45 +0900)
committerShotaro Yamada <sinkuu@sinkuu.xyz>
Fri, 27 Jul 2018 14:26:36 +0000 (23:26 +0900)
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/graph.rs
src/librustc/hir/pat_util.rs

index 78e57c6a5d78fb01afabd86525f0662a9343abe7..14a818ddafb710f09f8197d853480d097347fb23 100644 (file)
@@ -334,11 +334,8 @@ pub fn new_no_params(kind: DepKind) -> DepNode {
             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
                 }
index 1721d1dd0e9c578e436b1ae6a621083c888df68e..e308f2924a05c571c0efa4a4a24cdfc704c8789e 100644 (file)
@@ -489,7 +489,12 @@ pub fn register_dep_node_debug_str<F>(&self,
     }
 
     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) {
index 14989f1ff7d8aa3e5a29e457a575d6feee764f33..8a714a5fbd847173c8b2eefc82da51cf576dd0e2 100644 (file)
@@ -47,7 +47,7 @@ fn enumerate_and_adjust(self, expected_len: usize, gap_pos: Option<usize>)
         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,
         }
     }