Skip to content

Commit 40d4d32

Browse files
committed
Rename rustc command variable to compiler
1 parent 0b42f38 commit 40d4d32

File tree

1 file changed

+71
-70
lines changed

1 file changed

+71
-70
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,16 +1611,16 @@ impl<'test> TestCx<'test> {
16111611
) -> Command {
16121612
// FIXME(Zalathar): We should have a cleaner distinction between
16131613
// `rustc` flags, `rustdoc` flags, and flags shared by both.
1614-
let mut rustc = match compiler_kind {
1614+
let mut compiler = match compiler_kind {
16151615
CompilerKind::Rustc => Command::new(&self.config.rustc_path),
16161616
CompilerKind::Rustdoc => {
16171617
Command::new(&self.config.rustdoc_path.clone().expect("no rustdoc built yet"))
16181618
}
16191619
};
1620-
rustc.arg(input_file);
1620+
compiler.arg(input_file);
16211621

16221622
// Use a single thread for efficiency and a deterministic error message order
1623-
rustc.arg("-Zthreads=1");
1623+
compiler.arg("-Zthreads=1");
16241624

16251625
// Hide libstd sources from ui tests to make sure we generate the stderr
16261626
// output that users will see.
@@ -1630,19 +1630,19 @@ impl<'test> TestCx<'test> {
16301630
// This also has the benefit of more effectively normalizing output between different
16311631
// compilers, so that we don't have to know the `/rustc/$sha` output to normalize after the
16321632
// fact.
1633-
rustc.arg("-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX");
1634-
rustc.arg("-Ztranslate-remapped-path-to-local-path=no");
1633+
compiler.arg("-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX");
1634+
compiler.arg("-Ztranslate-remapped-path-to-local-path=no");
16351635

16361636
// Hide Cargo dependency sources from ui tests to make sure the error message doesn't
16371637
// change depending on whether $CARGO_HOME is remapped or not. If this is not present,
16381638
// when $CARGO_HOME is remapped the source won't be shown, and when it's not remapped the
16391639
// source will be shown, causing a blessing hell.
1640-
rustc.arg("-Z").arg(format!(
1640+
compiler.arg("-Z").arg(format!(
16411641
"ignore-directory-in-diagnostics-source-blocks={}",
16421642
home::cargo_home().expect("failed to find cargo home").to_str().unwrap()
16431643
));
16441644
// Similarly, vendored sources shouldn't be shown when running from a dist tarball.
1645-
rustc.arg("-Z").arg(format!(
1645+
compiler.arg("-Z").arg(format!(
16461646
"ignore-directory-in-diagnostics-source-blocks={}",
16471647
self.config.src_root.join("vendor"),
16481648
));
@@ -1654,12 +1654,12 @@ impl<'test> TestCx<'test> {
16541654
&& !self.config.host_rustcflags.iter().any(|flag| flag == "--sysroot")
16551655
{
16561656
// In stage 0, make sure we use `stage0-sysroot` instead of the bootstrap sysroot.
1657-
rustc.arg("--sysroot").arg(&self.config.sysroot_base);
1657+
compiler.arg("--sysroot").arg(&self.config.sysroot_base);
16581658
}
16591659

16601660
// If the provided codegen backend is not LLVM, we need to pass it.
16611661
if let Some(ref backend) = self.config.override_codegen_backend {
1662-
rustc.arg(format!("-Zcodegen-backend={}", backend));
1662+
compiler.arg(format!("-Zcodegen-backend={}", backend));
16631663
}
16641664

16651665
// Optionally prevent default --target if specified in test compile-flags.
@@ -1669,18 +1669,18 @@ impl<'test> TestCx<'test> {
16691669
let target =
16701670
if self.props.force_host { &*self.config.host } else { &*self.config.target };
16711671

1672-
rustc.arg(&format!("--target={}", target));
1672+
compiler.arg(&format!("--target={}", target));
16731673
}
1674-
self.set_revision_flags(&mut rustc);
1674+
self.set_revision_flags(&mut compiler);
16751675

16761676
if compiler_kind == CompilerKind::Rustc {
16771677
if let Some(ref incremental_dir) = self.props.incremental_dir {
1678-
rustc.args(&["-C", &format!("incremental={}", incremental_dir)]);
1679-
rustc.args(&["-Z", "incremental-verify-ich"]);
1678+
compiler.args(&["-C", &format!("incremental={}", incremental_dir)]);
1679+
compiler.args(&["-Z", "incremental-verify-ich"]);
16801680
}
16811681

16821682
if self.config.mode == TestMode::CodegenUnits {
1683-
rustc.args(&["-Z", "human_readable_cgu_names"]);
1683+
compiler.args(&["-Z", "human_readable_cgu_names"]);
16841684
}
16851685
}
16861686

@@ -1698,7 +1698,7 @@ impl<'test> TestCx<'test> {
16981698
.iter()
16991699
.any(|arg| arg == "-O" || arg.contains("opt-level"))
17001700
{
1701-
rustc.arg("-O");
1701+
compiler.arg("-O");
17021702
}
17031703
}
17041704
TestMode::DebugInfo => { /* debuginfo tests must be unoptimized */ }
@@ -1709,7 +1709,7 @@ impl<'test> TestCx<'test> {
17091709
// compile flags (below) or in per-test `compile-flags`.
17101710
}
17111711
_ => {
1712-
rustc.arg("-O");
1712+
compiler.arg("-O");
17131713
}
17141714
}
17151715
}
@@ -1730,24 +1730,24 @@ impl<'test> TestCx<'test> {
17301730
if self.props.error_patterns.is_empty()
17311731
&& self.props.regex_error_patterns.is_empty()
17321732
{
1733-
rustc.args(&["--error-format", "json"]);
1734-
rustc.args(&["--json", "future-incompat"]);
1733+
compiler.args(&["--error-format", "json"]);
1734+
compiler.args(&["--json", "future-incompat"]);
17351735
}
1736-
rustc.arg("-Zui-testing");
1737-
rustc.arg("-Zdeduplicate-diagnostics=no");
1736+
compiler.arg("-Zui-testing");
1737+
compiler.arg("-Zdeduplicate-diagnostics=no");
17381738
}
17391739
TestMode::Ui => {
17401740
if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) {
1741-
rustc.args(&["--error-format", "json"]);
1742-
rustc.args(&["--json", "future-incompat"]);
1741+
compiler.args(&["--error-format", "json"]);
1742+
compiler.args(&["--json", "future-incompat"]);
17431743
}
1744-
rustc.arg("-Ccodegen-units=1");
1744+
compiler.arg("-Ccodegen-units=1");
17451745
// Hide line numbers to reduce churn
1746-
rustc.arg("-Zui-testing");
1747-
rustc.arg("-Zdeduplicate-diagnostics=no");
1748-
rustc.arg("-Zwrite-long-types-to-disk=no");
1746+
compiler.arg("-Zui-testing");
1747+
compiler.arg("-Zdeduplicate-diagnostics=no");
1748+
compiler.arg("-Zwrite-long-types-to-disk=no");
17491749
// FIXME: use this for other modes too, for perf?
1750-
rustc.arg("-Cstrip=debuginfo");
1750+
compiler.arg("-Cstrip=debuginfo");
17511751
}
17521752
TestMode::MirOpt => {
17531753
// We check passes under test to minimize the mir-opt test dump
@@ -1759,7 +1759,7 @@ impl<'test> TestCx<'test> {
17591759
"-Zdump-mir=all".to_string()
17601760
};
17611761

1762-
rustc.args(&[
1762+
compiler.args(&[
17631763
"-Copt-level=1",
17641764
&zdump_arg,
17651765
"-Zvalidate-mir",
@@ -1769,45 +1769,46 @@ impl<'test> TestCx<'test> {
17691769
"--crate-type=rlib",
17701770
]);
17711771
if let Some(pass) = &self.props.mir_unit_test {
1772-
rustc.args(&["-Zmir-opt-level=0", &format!("-Zmir-enable-passes=+{}", pass)]);
1772+
compiler
1773+
.args(&["-Zmir-opt-level=0", &format!("-Zmir-enable-passes=+{}", pass)]);
17731774
} else {
1774-
rustc.args(&[
1775+
compiler.args(&[
17751776
"-Zmir-opt-level=4",
17761777
"-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals",
17771778
]);
17781779
}
17791780

1780-
set_mir_dump_dir(&mut rustc);
1781+
set_mir_dump_dir(&mut compiler);
17811782
}
17821783
TestMode::CoverageMap => {
1783-
rustc.arg("-Cinstrument-coverage");
1784+
compiler.arg("-Cinstrument-coverage");
17841785
// These tests only compile to LLVM IR, so they don't need the
17851786
// profiler runtime to be present.
1786-
rustc.arg("-Zno-profiler-runtime");
1787+
compiler.arg("-Zno-profiler-runtime");
17871788
// Coverage mappings are sensitive to MIR optimizations, and
17881789
// the current snapshots assume `opt-level=2` unless overridden
17891790
// by `compile-flags`.
1790-
rustc.arg("-Copt-level=2");
1791+
compiler.arg("-Copt-level=2");
17911792
}
17921793
TestMode::CoverageRun => {
1793-
rustc.arg("-Cinstrument-coverage");
1794+
compiler.arg("-Cinstrument-coverage");
17941795
// Coverage reports are sometimes sensitive to optimizations,
17951796
// and the current snapshots assume `opt-level=2` unless
17961797
// overridden by `compile-flags`.
1797-
rustc.arg("-Copt-level=2");
1798+
compiler.arg("-Copt-level=2");
17981799
}
17991800
TestMode::Assembly | TestMode::Codegen => {
1800-
rustc.arg("-Cdebug-assertions=no");
1801+
compiler.arg("-Cdebug-assertions=no");
18011802
// For assembly and codegen tests, we want to use the same order
18021803
// of the items of a codegen unit as the source order, so that
18031804
// we can compare the output with the source code through filecheck.
1804-
rustc.arg("-Zcodegen-source-order");
1805+
compiler.arg("-Zcodegen-source-order");
18051806
}
18061807
TestMode::Crashes => {
1807-
set_mir_dump_dir(&mut rustc);
1808+
set_mir_dump_dir(&mut compiler);
18081809
}
18091810
TestMode::CodegenUnits => {
1810-
rustc.arg("-Zprint-mono-items");
1811+
compiler.arg("-Zprint-mono-items");
18111812
}
18121813
TestMode::Pretty
18131814
| TestMode::DebugInfo
@@ -1820,7 +1821,7 @@ impl<'test> TestCx<'test> {
18201821
}
18211822

18221823
if self.props.remap_src_base {
1823-
rustc.arg(format!(
1824+
compiler.arg(format!(
18241825
"--remap-path-prefix={}={}",
18251826
self.config.src_test_suite_root, FAKE_SRC_BASE,
18261827
));
@@ -1830,19 +1831,19 @@ impl<'test> TestCx<'test> {
18301831
match emit {
18311832
Emit::None => {}
18321833
Emit::Metadata => {
1833-
rustc.args(&["--emit", "metadata"]);
1834+
compiler.args(&["--emit", "metadata"]);
18341835
}
18351836
Emit::LlvmIr => {
1836-
rustc.args(&["--emit", "llvm-ir"]);
1837+
compiler.args(&["--emit", "llvm-ir"]);
18371838
}
18381839
Emit::Mir => {
1839-
rustc.args(&["--emit", "mir"]);
1840+
compiler.args(&["--emit", "mir"]);
18401841
}
18411842
Emit::Asm => {
1842-
rustc.args(&["--emit", "asm"]);
1843+
compiler.args(&["--emit", "asm"]);
18431844
}
18441845
Emit::LinkArgsAsm => {
1845-
rustc.args(&["-Clink-args=--emit=asm"]);
1846+
compiler.args(&["-Clink-args=--emit=asm"]);
18461847
}
18471848
}
18481849
}
@@ -1851,7 +1852,7 @@ impl<'test> TestCx<'test> {
18511852
if self.config.target == "wasm32-unknown-unknown" || self.is_vxworks_pure_static() {
18521853
// rustc.arg("-g"); // get any backtrace at all on errors
18531854
} else if !self.props.no_prefer_dynamic {
1854-
rustc.args(&["-C", "prefer-dynamic"]);
1855+
compiler.args(&["-C", "prefer-dynamic"]);
18551856
}
18561857
}
18571858

@@ -1860,37 +1861,37 @@ impl<'test> TestCx<'test> {
18601861
// avoid a compiler warning about `--out-dir` being ignored.
18611862
_ if self.props.compile_flags.iter().any(|flag| flag == "-o") => {}
18621863
TargetLocation::ThisFile(path) => {
1863-
rustc.arg("-o").arg(path);
1864+
compiler.arg("-o").arg(path);
18641865
}
18651866
TargetLocation::ThisDirectory(path) => match compiler_kind {
18661867
CompilerKind::Rustdoc => {
18671868
// `rustdoc` uses `-o` for the output directory.
1868-
rustc.arg("-o").arg(path);
1869+
compiler.arg("-o").arg(path);
18691870
}
18701871
CompilerKind::Rustc => {
1871-
rustc.arg("--out-dir").arg(path);
1872+
compiler.arg("--out-dir").arg(path);
18721873
}
18731874
},
18741875
}
18751876

18761877
match self.config.compare_mode {
18771878
Some(CompareMode::Polonius) => {
1878-
rustc.args(&["-Zpolonius=next"]);
1879+
compiler.args(&["-Zpolonius=next"]);
18791880
}
18801881
Some(CompareMode::NextSolver) => {
1881-
rustc.args(&["-Znext-solver"]);
1882+
compiler.args(&["-Znext-solver"]);
18821883
}
18831884
Some(CompareMode::NextSolverCoherence) => {
1884-
rustc.args(&["-Znext-solver=coherence"]);
1885+
compiler.args(&["-Znext-solver=coherence"]);
18851886
}
18861887
Some(CompareMode::SplitDwarf) if self.config.target.contains("windows") => {
1887-
rustc.args(&["-Csplit-debuginfo=unpacked", "-Zunstable-options"]);
1888+
compiler.args(&["-Csplit-debuginfo=unpacked", "-Zunstable-options"]);
18881889
}
18891890
Some(CompareMode::SplitDwarf) => {
1890-
rustc.args(&["-Csplit-debuginfo=unpacked"]);
1891+
compiler.args(&["-Csplit-debuginfo=unpacked"]);
18911892
}
18921893
Some(CompareMode::SplitDwarfSingle) => {
1893-
rustc.args(&["-Csplit-debuginfo=packed"]);
1894+
compiler.args(&["-Csplit-debuginfo=packed"]);
18941895
}
18951896
None => {}
18961897
}
@@ -1899,44 +1900,44 @@ impl<'test> TestCx<'test> {
18991900
// overwrite this.
19001901
// Don't allow `unused_attributes` since these are usually actual mistakes, rather than just unused code.
19011902
if let AllowUnused::Yes = allow_unused {
1902-
rustc.args(&["-A", "unused", "-W", "unused_attributes"]);
1903+
compiler.args(&["-A", "unused", "-W", "unused_attributes"]);
19031904
}
19041905

19051906
// Allow tests to use internal features.
1906-
rustc.args(&["-A", "internal_features"]);
1907+
compiler.args(&["-A", "internal_features"]);
19071908

19081909
// Allow tests to have unused parens and braces.
19091910
// Add #![deny(unused_parens, unused_braces)] to the test file if you want to
19101911
// test that these lints are working.
1911-
rustc.args(&["-A", "unused_parens"]);
1912-
rustc.args(&["-A", "unused_braces"]);
1912+
compiler.args(&["-A", "unused_parens"]);
1913+
compiler.args(&["-A", "unused_braces"]);
19131914

19141915
if self.props.force_host {
1915-
self.maybe_add_external_args(&mut rustc, &self.config.host_rustcflags);
1916+
self.maybe_add_external_args(&mut compiler, &self.config.host_rustcflags);
19161917
if compiler_kind == CompilerKind::Rustc
19171918
&& let Some(ref linker) = self.config.host_linker
19181919
{
1919-
rustc.arg(format!("-Clinker={linker}"));
1920+
compiler.arg(format!("-Clinker={linker}"));
19201921
}
19211922
} else {
1922-
self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags);
1923+
self.maybe_add_external_args(&mut compiler, &self.config.target_rustcflags);
19231924
if compiler_kind == CompilerKind::Rustc
19241925
&& let Some(ref linker) = self.config.target_linker
19251926
{
1926-
rustc.arg(format!("-Clinker={linker}"));
1927+
compiler.arg(format!("-Clinker={linker}"));
19271928
}
19281929
}
19291930

19301931
// Use dynamic musl for tests because static doesn't allow creating dylibs
19311932
if self.config.host.contains("musl") || self.is_vxworks_pure_dynamic() {
1932-
rustc.arg("-Ctarget-feature=-crt-static");
1933+
compiler.arg("-Ctarget-feature=-crt-static");
19331934
}
19341935

19351936
if let LinkToAux::Yes = link_to_aux {
19361937
// if we pass an `-L` argument to a directory that doesn't exist,
19371938
// macOS ld emits warnings which disrupt the .stderr files
19381939
if self.has_aux_dir() {
1939-
rustc.arg("-L").arg(self.aux_output_dir_name());
1940+
compiler.arg("-L").arg(self.aux_output_dir_name());
19401941
}
19411942
}
19421943

@@ -1950,13 +1951,13 @@ impl<'test> TestCx<'test> {
19501951
//
19511952
// `minicore` requires `#![no_std]` and `#![no_core]`, which means no unwinding panics.
19521953
if self.props.add_minicore {
1953-
rustc.arg("-Cpanic=abort");
1954-
rustc.arg("-Cforce-unwind-tables=yes");
1954+
compiler.arg("-Cpanic=abort");
1955+
compiler.arg("-Cforce-unwind-tables=yes");
19551956
}
19561957

1957-
rustc.args(&self.props.compile_flags);
1958+
compiler.args(&self.props.compile_flags);
19581959

1959-
rustc
1960+
compiler
19601961
}
19611962

19621963
fn make_exe_name(&self) -> Utf8PathBuf {

0 commit comments

Comments
 (0)