summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-05-24 19:24:58 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2021-06-30 20:31:52 +0200
commit5f98e5ee5613abe3d8c2439af52d399bd6e98949 (patch)
tree095065a24d9aa44a26d8948e24ffc6ae95f3e6cf /compiler/rustc_interface/src
parent868c702d0c9a471a28fb55f0148eb1e3e8b1dcc5 (diff)
downloadrust-5f98e5ee5613abe3d8c2439af52d399bd6e98949.tar.gz
rust-5f98e5ee5613abe3d8c2439af52d399bd6e98949.zip
Simplify DepGraph creation.
Diffstat (limited to 'compiler/rustc_interface/src')
-rw-r--r--compiler/rustc_interface/src/queries.rs37
1 files changed, 12 insertions, 25 deletions
diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs
index 2320f0b47d2..e37a0347dcb 100644
--- a/compiler/rustc_interface/src/queries.rs
+++ b/compiler/rustc_interface/src/queries.rs
@@ -119,11 +119,8 @@ impl<'tcx> Queries<'tcx> {
 
     pub fn dep_graph_future(&self) -> Result<&Query<Option<DepGraphFuture>>> {
         self.dep_graph_future.compute(|| {
-            Ok(self
-                .session()
-                .opts
-                .build_dep_graph()
-                .then(|| rustc_incremental::load_dep_graph(self.session())))
+            let sess = self.session();
+            Ok(sess.opts.build_dep_graph().then(|| rustc_incremental::load_dep_graph(sess)))
         })
     }
 
@@ -195,27 +192,17 @@ impl<'tcx> Queries<'tcx> {
 
     pub fn dep_graph(&self) -> Result<&Query<DepGraph>> {
         self.dep_graph.compute(|| {
-            Ok(match self.dep_graph_future()?.take() {
-                None => DepGraph::new_disabled(),
-                Some(future) => {
+            let sess = self.session();
+            let future_opt = self.dep_graph_future()?.take();
+            let dep_graph = future_opt
+                .and_then(|future| {
                     let (prev_graph, prev_work_products) =
-                        self.session().time("blocked_on_dep_graph_loading", || {
-                            future
-                                .open()
-                                .unwrap_or_else(|e| rustc_incremental::LoadResult::Error {
-                                    message: format!("could not decode incremental cache: {:?}", e),
-                                })
-                                .open(self.session())
-                        });
-
-                    rustc_incremental::build_dep_graph(
-                        self.session(),
-                        prev_graph,
-                        prev_work_products,
-                    )
-                    .unwrap_or_else(DepGraph::new_disabled)
-                }
-            })
+                        sess.time("blocked_on_dep_graph_loading", || future.open().open(sess));
+
+                    rustc_incremental::build_dep_graph(sess, prev_graph, prev_work_products)
+                })
+                .unwrap_or_else(DepGraph::new_disabled);
+            Ok(dep_graph)
         })
     }