Skip to content

Commit 64feb9b

Browse files
committed
Auto merge of #134887 - Zalathar:rollup-ghpz7oy, r=Zalathar
Rollup of 5 pull requests Successful merges: - #134799 (nits: Cleanups in `librustdoc::clean`) - #134851 (docs: inline `alloc::ffi::c_str` types to `alloc::ffi`) - #134869 (Bump compiler cc) - #134876 (bootstrap: Consolidate the macros for declaring compiletest test suites) - #134883 (bootstrap: Fix `./x check bootstrap` by moving `shared_helpers::tests`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e7738af + fc89cb2 commit 64feb9b

File tree

10 files changed

+142
-123
lines changed

10 files changed

+142
-123
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ version = "0.1.0"
405405

406406
[[package]]
407407
name = "cc"
408-
version = "1.2.5"
408+
version = "1.2.6"
409409
source = "registry+https://github.com/rust-lang/crates.io-index"
410-
checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e"
410+
checksum = "8d6dbb628b8f8555f86d0323c2eb39e3ec81901f4b83e091db8a6a76d316a333"
411411
dependencies = [
412412
"shlex",
413413
]

compiler/rustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ arrayvec = { version = "0.7", default-features = false }
1010
bitflags = "2.4.1"
1111
# Pinned so `cargo update` bumps don't cause breakage. Please also update the
1212
# `cc` in `rustc_llvm` if you update the `cc` here.
13-
cc = "=1.2.5"
13+
cc = "=1.2.6"
1414
either = "1.5.0"
1515
itertools = "0.12"
1616
pathdiff = "0.2.0"

compiler/rustc_llvm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ libc = "0.2.73"
1212
# tidy-alphabetical-start
1313
# Pinned so `cargo update` bumps don't cause breakage. Please also update the
1414
# pinned `cc` in `rustc_codegen_ssa` if you update `cc` here.
15-
cc = "=1.2.5"
15+
cc = "=1.2.6"
1616
# tidy-alphabetical-end

library/alloc/src/ffi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
#[doc(inline)]
8484
#[stable(feature = "alloc_c_string", since = "1.64.0")]
8585
pub use self::c_str::CString;
86-
#[doc(no_inline)]
86+
#[doc(inline)]
8787
#[stable(feature = "alloc_c_string", since = "1.64.0")]
8888
pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError};
8989

src/bootstrap/src/core/build_steps/test.rs

+113-103
Original file line numberDiff line numberDiff line change
@@ -1133,69 +1133,21 @@ fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
11331133
builder.out.join(host).join("test")
11341134
}
11351135

1136-
macro_rules! default_test {
1137-
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1138-
test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: false });
1139-
};
1140-
}
1141-
1142-
macro_rules! default_test_with_compare_mode {
1143-
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr,
1144-
compare_mode: $compare_mode:expr }) => {
1145-
test_with_compare_mode!($name {
1146-
path: $path,
1147-
mode: $mode,
1148-
suite: $suite,
1149-
default: true,
1150-
host: false,
1151-
compare_mode: $compare_mode
1152-
});
1153-
};
1154-
}
1155-
1156-
macro_rules! host_test {
1157-
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr }) => {
1158-
test!($name { path: $path, mode: $mode, suite: $suite, default: true, host: true });
1159-
};
1160-
}
1161-
1136+
/// Declares a test step that invokes compiletest on a particular test suite.
11621137
macro_rules! test {
1163-
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1164-
host: $host:expr }) => {
1165-
test_definitions!($name {
1166-
path: $path,
1167-
mode: $mode,
1168-
suite: $suite,
1169-
default: $default,
1170-
host: $host,
1171-
compare_mode: None
1172-
});
1173-
};
1174-
}
1175-
1176-
macro_rules! test_with_compare_mode {
1177-
($name:ident { path: $path:expr, mode: $mode:expr, suite: $suite:expr, default: $default:expr,
1178-
host: $host:expr, compare_mode: $compare_mode:expr }) => {
1179-
test_definitions!($name {
1180-
path: $path,
1181-
mode: $mode,
1182-
suite: $suite,
1183-
default: $default,
1184-
host: $host,
1185-
compare_mode: Some($compare_mode)
1186-
});
1187-
};
1188-
}
1189-
1190-
macro_rules! test_definitions {
1191-
($name:ident {
1192-
path: $path:expr,
1193-
mode: $mode:expr,
1194-
suite: $suite:expr,
1195-
default: $default:expr,
1196-
host: $host:expr,
1197-
compare_mode: $compare_mode:expr
1198-
}) => {
1138+
(
1139+
$( #[$attr:meta] )* // allow docstrings and attributes
1140+
$name:ident {
1141+
path: $path:expr,
1142+
mode: $mode:expr,
1143+
suite: $suite:expr,
1144+
default: $default:expr
1145+
$( , only_hosts: $only_hosts:expr )? // default: false
1146+
$( , compare_mode: $compare_mode:expr )? // default: None
1147+
$( , )? // optional trailing comma
1148+
}
1149+
) => {
1150+
$( #[$attr] )*
11991151
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12001152
pub struct $name {
12011153
pub compiler: Compiler,
@@ -1205,7 +1157,12 @@ macro_rules! test_definitions {
12051157
impl Step for $name {
12061158
type Output = ();
12071159
const DEFAULT: bool = $default;
1208-
const ONLY_HOSTS: bool = $host;
1160+
const ONLY_HOSTS: bool = (const {
1161+
#[allow(unused_assignments, unused_mut)]
1162+
let mut value = false;
1163+
$( value = $only_hosts; )?
1164+
value
1165+
});
12091166

12101167
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
12111168
run.suite_path($path)
@@ -1224,21 +1181,31 @@ macro_rules! test_definitions {
12241181
mode: $mode,
12251182
suite: $suite,
12261183
path: $path,
1227-
compare_mode: $compare_mode,
1184+
compare_mode: (const {
1185+
#[allow(unused_assignments, unused_mut)]
1186+
let mut value = None;
1187+
$( value = $compare_mode; )?
1188+
value
1189+
}),
12281190
})
12291191
}
12301192
}
12311193
};
12321194
}
12331195

12341196
/// Declares an alias for running the [`Coverage`] tests in only one mode.
1235-
/// Adapted from [`test_definitions`].
1197+
/// Adapted from [`test`].
12361198
macro_rules! coverage_test_alias {
1237-
($name:ident {
1238-
alias_and_mode: $alias_and_mode:expr, // &'static str
1239-
default: $default:expr, // bool
1240-
only_hosts: $only_hosts:expr $(,)? // bool
1241-
}) => {
1199+
(
1200+
$( #[$attr:meta] )* // allow docstrings and attributes
1201+
$name:ident {
1202+
alias_and_mode: $alias_and_mode:expr, // &'static str
1203+
default: $default:expr, // bool
1204+
only_hosts: $only_hosts:expr // bool
1205+
$( , )? // optional trailing comma
1206+
}
1207+
) => {
1208+
$( #[$attr] )*
12421209
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12431210
pub struct $name {
12441211
pub compiler: Compiler,
@@ -1410,37 +1377,74 @@ impl Step for CrateBuildHelper {
14101377
}
14111378
}
14121379

1413-
default_test!(Ui { path: "tests/ui", mode: "ui", suite: "ui" });
1380+
test!(Ui { path: "tests/ui", mode: "ui", suite: "ui", default: true });
14141381

1415-
default_test!(Crashes { path: "tests/crashes", mode: "crashes", suite: "crashes" });
1382+
test!(Crashes { path: "tests/crashes", mode: "crashes", suite: "crashes", default: true });
14161383

1417-
default_test!(Codegen { path: "tests/codegen", mode: "codegen", suite: "codegen" });
1384+
test!(Codegen { path: "tests/codegen", mode: "codegen", suite: "codegen", default: true });
14181385

1419-
default_test!(CodegenUnits {
1386+
test!(CodegenUnits {
14201387
path: "tests/codegen-units",
14211388
mode: "codegen-units",
1422-
suite: "codegen-units"
1389+
suite: "codegen-units",
1390+
default: true,
14231391
});
14241392

1425-
default_test!(Incremental { path: "tests/incremental", mode: "incremental", suite: "incremental" });
1393+
test!(Incremental {
1394+
path: "tests/incremental",
1395+
mode: "incremental",
1396+
suite: "incremental",
1397+
default: true,
1398+
});
14261399

1427-
default_test_with_compare_mode!(Debuginfo {
1400+
test!(Debuginfo {
14281401
path: "tests/debuginfo",
14291402
mode: "debuginfo",
14301403
suite: "debuginfo",
1431-
compare_mode: "split-dwarf"
1404+
default: true,
1405+
compare_mode: Some("split-dwarf"),
14321406
});
14331407

1434-
host_test!(UiFullDeps { path: "tests/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" });
1408+
test!(UiFullDeps {
1409+
path: "tests/ui-fulldeps",
1410+
mode: "ui",
1411+
suite: "ui-fulldeps",
1412+
default: true,
1413+
only_hosts: true,
1414+
});
14351415

1436-
host_test!(Rustdoc { path: "tests/rustdoc", mode: "rustdoc", suite: "rustdoc" });
1437-
host_test!(RustdocUi { path: "tests/rustdoc-ui", mode: "ui", suite: "rustdoc-ui" });
1416+
test!(Rustdoc {
1417+
path: "tests/rustdoc",
1418+
mode: "rustdoc",
1419+
suite: "rustdoc",
1420+
default: true,
1421+
only_hosts: true,
1422+
});
1423+
test!(RustdocUi {
1424+
path: "tests/rustdoc-ui",
1425+
mode: "ui",
1426+
suite: "rustdoc-ui",
1427+
default: true,
1428+
only_hosts: true,
1429+
});
14381430

1439-
host_test!(RustdocJson { path: "tests/rustdoc-json", mode: "rustdoc-json", suite: "rustdoc-json" });
1431+
test!(RustdocJson {
1432+
path: "tests/rustdoc-json",
1433+
mode: "rustdoc-json",
1434+
suite: "rustdoc-json",
1435+
default: true,
1436+
only_hosts: true,
1437+
});
14401438

1441-
host_test!(Pretty { path: "tests/pretty", mode: "pretty", suite: "pretty" });
1439+
test!(Pretty {
1440+
path: "tests/pretty",
1441+
mode: "pretty",
1442+
suite: "pretty",
1443+
default: true,
1444+
only_hosts: true,
1445+
});
14421446

1443-
/// Special-handling is needed for `run-make`, so don't use `default_test` for defining `RunMake`
1447+
/// Special-handling is needed for `run-make`, so don't use `test!` for defining `RunMake`
14441448
/// tests.
14451449
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
14461450
pub struct RunMake {
@@ -1475,7 +1479,7 @@ impl Step for RunMake {
14751479
}
14761480
}
14771481

1478-
default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly" });
1482+
test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly", default: true });
14791483

14801484
/// Coverage tests are a bit more complicated than other test suites, because
14811485
/// we want to run the same set of test files in multiple different modes,
@@ -1552,27 +1556,33 @@ impl Step for Coverage {
15521556
}
15531557
}
15541558

1555-
// Runs `tests/coverage` in "coverage-map" mode only.
1556-
// Used by `x test` and `x test coverage-map`.
1557-
coverage_test_alias!(CoverageMap {
1558-
alias_and_mode: "coverage-map",
1559-
default: true,
1560-
only_hosts: false,
1561-
});
1562-
// Runs `tests/coverage` in "coverage-run" mode only.
1563-
// Used by `x test` and `x test coverage-run`.
1564-
coverage_test_alias!(CoverageRun {
1565-
alias_and_mode: "coverage-run",
1566-
default: true,
1567-
// Compiletest knows how to automatically skip these tests when cross-compiling,
1568-
// but skipping the whole step here makes it clearer that they haven't run at all.
1569-
only_hosts: true,
1570-
});
1559+
coverage_test_alias! {
1560+
/// Runs the `tests/coverage` test suite in "coverage-map" mode only.
1561+
/// Used by `x test` and `x test coverage-map`.
1562+
CoverageMap {
1563+
alias_and_mode: "coverage-map",
1564+
default: true,
1565+
only_hosts: false,
1566+
}
1567+
}
1568+
coverage_test_alias! {
1569+
/// Runs the `tests/coverage` test suite in "coverage-run" mode only.
1570+
/// Used by `x test` and `x test coverage-run`.
1571+
CoverageRun {
1572+
alias_and_mode: "coverage-run",
1573+
default: true,
1574+
// Compiletest knows how to automatically skip these tests when cross-compiling,
1575+
// but skipping the whole step here makes it clearer that they haven't run at all.
1576+
only_hosts: true,
1577+
}
1578+
}
15711579

1572-
host_test!(CoverageRunRustdoc {
1580+
test!(CoverageRunRustdoc {
15731581
path: "tests/coverage-run-rustdoc",
15741582
mode: "coverage-run",
1575-
suite: "coverage-run-rustdoc"
1583+
suite: "coverage-run-rustdoc",
1584+
default: true,
1585+
only_hosts: true,
15761586
});
15771587

15781588
// For the mir-opt suite we do not use macros, as we need custom behavior when blessing.

src/bootstrap/src/utils/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ pub(crate) mod metrics;
1414
pub(crate) mod render_tests;
1515
pub(crate) mod shared_helpers;
1616
pub(crate) mod tarball;
17+
#[cfg(test)]
18+
mod tests;

src/bootstrap/src/utils/shared_helpers.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use std::io::Write;
1313
use std::process::Command;
1414
use std::str::FromStr;
1515

16-
#[cfg(test)]
17-
mod tests;
16+
// If we were to declare a tests submodule here, the shim binaries that include this
17+
// module via `#[path]` would fail to find it, which breaks `./x check bootstrap`.
18+
// So instead the unit tests for this module are in `super::tests::shared_helpers_tests`.
1819

1920
/// Returns the environment variable which the dynamic library lookup path
2021
/// resides in for this platform.

src/bootstrap/src/utils/tests/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mod shared_helpers_tests;

src/bootstrap/src/utils/shared_helpers/tests.rs src/bootstrap/src/utils/tests/shared_helpers_tests.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
use super::parse_value_from_args;
1+
//! The `shared_helpers` module can't have its own tests submodule, because
2+
//! that would cause problems for the shim binaries that include it via
3+
//! `#[path]`, so instead those unit tests live here.
4+
//!
5+
//! To prevent tidy from complaining about this file not being named `tests.rs`,
6+
//! it lives inside a submodule directory named `tests`.
7+
8+
use crate::utils::shared_helpers::parse_value_from_args;
29

310
#[test]
411
fn test_parse_value_from_args() {

0 commit comments

Comments
 (0)