]> git.lizzy.rs Git - rust.git/commitdiff
Move call site of `dep_graph_future()`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 30 Aug 2019 06:53:34 +0000 (16:53 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Wed, 11 Sep 2019 00:59:05 +0000 (10:59 +1000)
`Compiler::register_plugins()` calls `passes::register_plugins()`, which
calls `Compiler::dep_graph_future()`. This is the only way in which a
`passes` function calls a `Compiler` function.

This commit moves the `dep_graph_future()` call out of
`passes::register_plugins()` and into `Compiler::register_plugins()`,
which is a more sensible spot for it. This will delay the loading of the
dep graph slightly -- from the middle of plugin registration to the end
of plugin registration -- but plugin registration is fast enough
(especially compared to expansion) that the impact should be neglible.

src/librustc_interface/passes.rs
src/librustc_interface/queries.rs

index 24b44964e4fd22b08fa676c567883554322c0065..200da05c57561f2d3d725fdccce77b6db9eb42f8 100644 (file)
@@ -223,7 +223,6 @@ pub struct PluginInfo {
 }
 
 pub fn register_plugins<'a>(
-    compiler: &Compiler,
     sess: &'a Session,
     cstore: &'a CStore,
     mut krate: ast::Crate,
@@ -261,9 +260,6 @@ pub fn register_plugins<'a>(
         });
     }
 
-    // If necessary, compute the dependency graph (in the background).
-    compiler.dep_graph_future().ok();
-
     time(sess, "recursion limit", || {
         middle::recursion_limit::update_limits(sess, &krate);
     });
index c281bc5360704996f8e965eb9a6c3ef52b82d5bc..e056d3feb66ec0a0532f8ad8bbbbab1b7bfe0750 100644 (file)
@@ -114,13 +114,21 @@ pub fn register_plugins(&self) -> Result<&Query<(ast::Crate, PluginInfo)>> {
             let crate_name = self.crate_name()?.peek().clone();
             let krate = self.parse()?.take();
 
-            passes::register_plugins(
-                self,
+            let result = passes::register_plugins(
                 self.session(),
                 self.cstore(),
                 krate,
                 &crate_name,
-            )
+            );
+
+            // Compute the dependency graph (in the background). We want to do
+            // this as early as possible, to give the DepGraph maximum time to
+            // load before dep_graph() is called, but it also can't happen
+            // until after rustc_incremental::prepare_session_directory() is
+            // called, which happens within passes::register_plugins().
+            self.dep_graph_future().ok();
+
+            result
         })
     }