From c2fa99d2c6671ef9771df76335f6b528847e598c Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 19 Dec 2018 13:19:48 +0100 Subject: [PATCH] query: minor refactoring --- src/librustc/ty/query/job.rs | 7 ++----- src/librustc/ty/query/on_disk_cache.rs | 6 +----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index 559093b8f189..4ee5ef6b1fd0 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -406,7 +406,7 @@ fn remove_cycle<'tcx>( // Find the queries in the cycle which are // connected to queries outside the cycle - let entry_points: Vec<_> = stack.iter().filter_map(|(span, query)| { + let entry_points = stack.iter().filter_map(|(span, query)| { if query.parent.is_none() { // This query is connected to the root (it has no query parent) Some((*span, query.clone(), None)) @@ -431,10 +431,7 @@ fn remove_cycle<'tcx>( Some((*span, query.clone(), Some(waiter))) } } - }).collect(); - - let entry_points: Vec<(Span, Lrc>, Option<(Span, Lrc>)>)> - = entry_points; + }).collect::>, Option<(Span, Lrc>)>)>>(); // Deterministically pick an entry point let (_, entry_point, usage) = pick_query(tcx, &entry_points, |e| (e.0, e.1.clone())); diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 04c880826fe7..94456e3e773d 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -398,11 +398,7 @@ impl<'sess> OnDiskCache<'sess> { -> Option where T: Decodable { - let pos = if let Some(&pos) = index.get(&dep_node_index) { - pos - } else { - return None - }; + let pos = index.get(&dep_node_index).cloned()?; // Initialize the cnum_map using the value from the thread which finishes the closure first self.cnum_map.init_nonlocking_same(|| {