about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2024-10-11 17:46:12 +1100
committerGitHub <noreply@github.com>2024-10-11 17:46:12 +1100
commit3bb522202f5cd3fe9d30c29a29eaf5e423e5ee06 (patch)
tree21a5261f44c2a048c6dad7fc4ff7893a4451071f
parentf6bdf711cfe3fce10408fb47a432f4c6258f8025 (diff)
parent4637630ed7e64a5a3f56ff8e4f5d2552f0df455b (diff)
downloadrust-3bb522202f5cd3fe9d30c29a29eaf5e423e5ee06.tar.gz
rust-3bb522202f5cd3fe9d30c29a29eaf5e423e5ee06.zip
Rollup merge of #131525 - Zalathar:emit-asm, r=jieyouxu
compiletest: Simplify the choice of `--emit` mode for assembly tests

Tiny little cleanup that I noticed while working on #131524. No functional change.

Historically, the original code structure (#58791) predates the `Emit` enum (#103298), so it was manually adding `--emit` flags to the compiler invocation. But now the match can just evaluate to the appropriate `Emit` value directly.
-rw-r--r--src/tools/compiletest/src/runtest.rs25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 5e75a74a64c..1baf0c56e37 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1804,23 +1804,14 @@ impl<'test> TestCx<'test> {
         let output_path = self.output_base_name().with_extension("s");
         let input_file = &self.testpaths.file;
 
-        let mut emit = Emit::None;
-        match self.props.assembly_output.as_ref().map(AsRef::as_ref) {
-            Some("emit-asm") => {
-                emit = Emit::Asm;
-            }
-
-            Some("bpf-linker") => {
-                emit = Emit::LinkArgsAsm;
-            }
-
-            Some("ptx-linker") => {
-                // No extra flags needed.
-            }
-
-            Some(header) => self.fatal(&format!("unknown 'assembly-output' header: {header}")),
-            None => self.fatal("missing 'assembly-output' header"),
-        }
+        // Use the `//@ assembly-output:` directive to determine how to emit assembly.
+        let emit = match self.props.assembly_output.as_deref() {
+            Some("emit-asm") => Emit::Asm,
+            Some("bpf-linker") => Emit::LinkArgsAsm,
+            Some("ptx-linker") => Emit::None, // No extra flags needed.
+            Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")),
+            None => self.fatal("missing 'assembly-output' directive"),
+        };
 
         let rustc = self.make_compile_args(
             input_file,