Skip to content

Commit df952ca

Browse files
committed
Move call site of dep_graph_future().
`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.
1 parent c6117d9 commit df952ca

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/librustc_interface/passes.rs

-4
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ pub struct PluginInfo {
223223
}
224224

225225
pub fn register_plugins<'a>(
226-
compiler: &Compiler,
227226
sess: &'a Session,
228227
cstore: &'a CStore,
229228
mut krate: ast::Crate,
@@ -261,9 +260,6 @@ pub fn register_plugins<'a>(
261260
});
262261
}
263262

264-
// If necessary, compute the dependency graph (in the background).
265-
compiler.dep_graph_future().ok();
266-
267263
time(sess, "recursion limit", || {
268264
middle::recursion_limit::update_limits(sess, &krate);
269265
});

src/librustc_interface/queries.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,21 @@ impl Compiler {
113113
let crate_name = self.crate_name()?.peek().clone();
114114
let krate = self.parse()?.take();
115115

116-
passes::register_plugins(
117-
self,
116+
let result = passes::register_plugins(
118117
self.session(),
119118
self.cstore(),
120119
krate,
121120
&crate_name,
122-
)
121+
);
122+
123+
// Compute the dependency graph (in the background). We want to do
124+
// this as early as possible, to give the DepGraph maximum time to
125+
// load before dep_graph() is called, but it also can't happen
126+
// until after rustc_incremental::prepare_session_directory() is
127+
// called, which happens within passes::register_plugins().
128+
self.dep_graph_future().ok();
129+
130+
result
123131
})
124132
}
125133

0 commit comments

Comments
 (0)