about summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-05-30 17:39:45 +0000
committerbors <bors@rust-lang.org>2021-05-30 17:39:45 +0000
commit758c00ea4088e1ca2714890f00c791c24f001536 (patch)
tree3dc3ae07477da729258bac33d960e11d79110019 /compiler/rustc_session/src
parent59579907ab52ad2369735622185a26f158bf0f0f (diff)
parentb14b7c6085a7bc4cbf6614ebe98a62847884e5a5 (diff)
downloadrust-758c00ea4088e1ca2714890f00c791c24f001536.tar.gz
rust-758c00ea4088e1ca2714890f00c791c24f001536.zip
Auto merge of #85362 - jsgf:fix-emit-metadata, r=estebank
Use command line metadata path if provided

If the command-line has `--emit metadata=some/path/libfoo.rmeta` then
use that.

Closes #85356

I couldn't find any existing tests for the `--emit TYPE=PATH` command line syntax, so I wasn't sure how to test this aside from ad-hoc manual testing. Is there a ui test type for "generated output file with expected name"?
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/output.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs
index 777eea3f68d..cc1e4bb198a 100644
--- a/compiler/rustc_session/src/output.rs
+++ b/compiler/rustc_session/src/output.rs
@@ -127,6 +127,11 @@ pub fn filename_for_metadata(
     crate_name: &str,
     outputs: &OutputFilenames,
 ) -> PathBuf {
+    // If the command-line specified the path, use that directly.
+    if let Some(Some(out_filename)) = sess.opts.output_types.get(&OutputType::Metadata) {
+        return out_filename.clone();
+    }
+
     let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
 
     let out_filename = outputs