Skip to content

Commit 0b42f38

Browse files
committed
Replace is_rustdoc with clearer compiler-kind checks
1 parent 5e629be commit 0b42f38

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,7 +1609,8 @@ impl<'test> TestCx<'test> {
16091609
link_to_aux: LinkToAux,
16101610
passes: Vec<String>, // Vec of passes under mir-opt test to be dumped
16111611
) -> Command {
1612-
let is_rustdoc = compiler_kind == CompilerKind::Rustdoc;
1612+
// FIXME(Zalathar): We should have a cleaner distinction between
1613+
// `rustc` flags, `rustdoc` flags, and flags shared by both.
16131614
let mut rustc = match compiler_kind {
16141615
CompilerKind::Rustc => Command::new(&self.config.rustc_path),
16151616
CompilerKind::Rustdoc => {
@@ -1672,7 +1673,7 @@ impl<'test> TestCx<'test> {
16721673
}
16731674
self.set_revision_flags(&mut rustc);
16741675

1675-
if !is_rustdoc {
1676+
if compiler_kind == CompilerKind::Rustc {
16761677
if let Some(ref incremental_dir) = self.props.incremental_dir {
16771678
rustc.args(&["-C", &format!("incremental={}", incremental_dir)]);
16781679
rustc.args(&["-Z", "incremental-verify-ich"]);
@@ -1683,7 +1684,7 @@ impl<'test> TestCx<'test> {
16831684
}
16841685
}
16851686

1686-
if self.config.optimize_tests && !is_rustdoc {
1687+
if self.config.optimize_tests && compiler_kind == CompilerKind::Rustc {
16871688
match self.config.mode {
16881689
TestMode::Ui => {
16891690
// If optimize-tests is true we still only want to optimize tests that actually get
@@ -1825,27 +1826,28 @@ impl<'test> TestCx<'test> {
18251826
));
18261827
}
18271828

1828-
match emit {
1829-
Emit::None => {}
1830-
Emit::Metadata if is_rustdoc => {}
1831-
Emit::Metadata => {
1832-
rustc.args(&["--emit", "metadata"]);
1833-
}
1834-
Emit::LlvmIr => {
1835-
rustc.args(&["--emit", "llvm-ir"]);
1836-
}
1837-
Emit::Mir => {
1838-
rustc.args(&["--emit", "mir"]);
1839-
}
1840-
Emit::Asm => {
1841-
rustc.args(&["--emit", "asm"]);
1842-
}
1843-
Emit::LinkArgsAsm => {
1844-
rustc.args(&["-Clink-args=--emit=asm"]);
1829+
if compiler_kind == CompilerKind::Rustc {
1830+
match emit {
1831+
Emit::None => {}
1832+
Emit::Metadata => {
1833+
rustc.args(&["--emit", "metadata"]);
1834+
}
1835+
Emit::LlvmIr => {
1836+
rustc.args(&["--emit", "llvm-ir"]);
1837+
}
1838+
Emit::Mir => {
1839+
rustc.args(&["--emit", "mir"]);
1840+
}
1841+
Emit::Asm => {
1842+
rustc.args(&["--emit", "asm"]);
1843+
}
1844+
Emit::LinkArgsAsm => {
1845+
rustc.args(&["-Clink-args=--emit=asm"]);
1846+
}
18451847
}
18461848
}
18471849

1848-
if !is_rustdoc {
1850+
if compiler_kind == CompilerKind::Rustc {
18491851
if self.config.target == "wasm32-unknown-unknown" || self.is_vxworks_pure_static() {
18501852
// rustc.arg("-g"); // get any backtrace at all on errors
18511853
} else if !self.props.no_prefer_dynamic {
@@ -1860,14 +1862,15 @@ impl<'test> TestCx<'test> {
18601862
TargetLocation::ThisFile(path) => {
18611863
rustc.arg("-o").arg(path);
18621864
}
1863-
TargetLocation::ThisDirectory(path) => {
1864-
if is_rustdoc {
1865+
TargetLocation::ThisDirectory(path) => match compiler_kind {
1866+
CompilerKind::Rustdoc => {
18651867
// `rustdoc` uses `-o` for the output directory.
18661868
rustc.arg("-o").arg(path);
1867-
} else {
1869+
}
1870+
CompilerKind::Rustc => {
18681871
rustc.arg("--out-dir").arg(path);
18691872
}
1870-
}
1873+
},
18711874
}
18721875

18731876
match self.config.compare_mode {
@@ -1910,17 +1913,17 @@ impl<'test> TestCx<'test> {
19101913

19111914
if self.props.force_host {
19121915
self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags);
1913-
if !is_rustdoc {
1914-
if let Some(ref linker) = self.config.host_linker {
1915-
rustc.arg(format!("-Clinker={}", linker));
1916-
}
1916+
if compiler_kind == CompilerKind::Rustc
1917+
&& let Some(ref linker) = self.config.host_linker
1918+
{
1919+
rustc.arg(format!("-Clinker={linker}"));
19171920
}
19181921
} else {
19191922
self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
1920-
if !is_rustdoc {
1921-
if let Some(ref linker) = self.config.target_linker {
1922-
rustc.arg(format!("-Clinker={}", linker));
1923-
}
1923+
if compiler_kind == CompilerKind::Rustc
1924+
&& let Some(ref linker) = self.config.target_linker
1925+
{
1926+
rustc.arg(format!("-Clinker={linker}"));
19241927
}
19251928
}
19261929

0 commit comments

Comments
 (0)