]> git.lizzy.rs Git - rust.git/commitdiff
Add a comment to `Compiler::compile()`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 30 Aug 2019 07:27:35 +0000 (17:27 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Wed, 18 Sep 2019 20:56:52 +0000 (06:56 +1000)
`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.

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

index e056d3feb66ec0a0532f8ad8bbbbab1b7bfe0750..ff5cd8b8c695d2fbc2dac7efa04fc271fc6c0cce 100644 (file)
@@ -275,6 +275,11 @@ pub fn link(&self) -> Result<&Query<()>> {
         })
     }
 
+    // This method is different to all the other methods in `Compiler` because
+    // it lacks a `Queries` entry. It's also not currently used. It does serve
+    // as an example of how `Compiler` can be used, with additional steps added
+    // between some passes. And see `rustc_driver::run_compiler` for a more
+    // complex example.
     pub fn compile(&self) -> Result<()> {
         self.prepare_outputs()?;
 
@@ -286,12 +291,12 @@ pub fn compile(&self) -> Result<()> {
 
         self.global_ctxt()?;
 
-        // Drop AST after creating GlobalCtxt to free memory
+        // Drop AST after creating GlobalCtxt to free memory.
         mem::drop(self.expansion()?.take());
 
         self.ongoing_codegen()?;
 
-        // Drop GlobalCtxt after starting codegen to free memory
+        // Drop GlobalCtxt after starting codegen to free memory.
         mem::drop(self.global_ctxt()?.take());
 
         self.link().map(|_| ())
index afc92638fda978c767f917da8872e07b149d8878..e290f7fa6b13a97d0fbb1e08fe2d43c55448f683 100644 (file)
@@ -62,6 +62,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
     };
 
     interface::run_compiler(config, |compiler| {
-        compiler.compile().ok();
+        // This runs all the passes prior to linking, too.
+        compiler.link().ok();
     });
 }