Skip to content

Commit 2521189

Browse files
committed
Add a comment to Compiler::compile().
`Compiler::compile()` is different to all the other `Compiler` methods because it lacks a `Queries` entry. It only has one call site, which is in a test that doesn't need its specific characteristics. This patch replaces that call with a call to `Compile::link()`, which is similar enough for the test's purposes. It also notes that the method is an illustrative example of how `Compiler` can be used.
1 parent d264a56 commit 2521189

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/librustc_interface/queries.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ impl Compiler {
275275
})
276276
}
277277

278+
// This method is different to all the other methods in `Compiler` because
279+
// it lacks a `Queries` entry. It's also not currently used. It does serve
280+
// as an example of how `Compiler` can be used, with additional steps added
281+
// between some passes. And see `rustc_driver::run_compiler` for a more
282+
// complex example.
278283
pub fn compile(&self) -> Result<()> {
279284
self.prepare_outputs()?;
280285

@@ -286,12 +291,12 @@ impl Compiler {
286291

287292
self.global_ctxt()?;
288293

289-
// Drop AST after creating GlobalCtxt to free memory
294+
// Drop AST after creating GlobalCtxt to free memory.
290295
mem::drop(self.expansion()?.take());
291296

292297
self.ongoing_codegen()?;
293298

294-
// Drop GlobalCtxt after starting codegen to free memory
299+
// Drop GlobalCtxt after starting codegen to free memory.
295300
mem::drop(self.global_ctxt()?.take());
296301

297302
self.link().map(|_| ())

src/test/run-make-fulldeps/issue-19371/foo.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
6262
};
6363

6464
interface::run_compiler(config, |compiler| {
65-
compiler.compile().ok();
65+
// This runs all the passes prior to linking, too.
66+
compiler.link().ok();
6667
});
6768
}

0 commit comments

Comments
 (0)