Skip to content

Commit b15a874

Browse files
committed
Auto merge of rust-lang#148305 - RalfJung:add-minicore, r=jieyouxu,wesleywiser
compiletest: rename `add-core-stubs`/`core-stubs-compile-flags` to `add-minicore`/`minicore-compile-flags` Fixes rust-lang#148282
2 parents 8483293 + 97d8f3e commit b15a874

File tree

276 files changed

+320
-323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+320
-323
lines changed

src/doc/rustc-dev-guide/src/tests/minicore.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ range of tests.
1414

1515
</div>
1616

17-
A test can use [`minicore`] by specifying the `//@ add-core-stubs` directive.
18-
Then, mark the test with `#![feature(no_core)]` + `#![no_std]` + `#![no_core]`.
19-
Due to Edition 2015 extern prelude rules, you will probably need to declare
20-
`minicore` as an extern crate.
17+
A test can use [`minicore`] by specifying the `//@ add-minicore` directive.
18+
Then, mark the test with `#![feature(no_core)]` + `#![no_std]` + `#![no_core]`,
19+
and import the crate into the test with `extern crate minicore` (edition 2015)
20+
or `use minicore` (edition 2018+).
2121

2222
## Implied compiler flags
2323

24-
Due to the `no_std` + `no_core` nature of these tests, `//@ add-core-stubs`
24+
Due to the `no_std` + `no_core` nature of these tests, `//@ add-minicore`
2525
implies and requires that the test will be built with `-C panic=abort`.
2626
**Unwinding panics are not supported.**
2727

2828
Tests will also be built with `-C force-unwind-tables=yes` to preserve CFI
2929
directives in assembly tests.
3030

31-
TL;DR: `//@ add-core-stubs` implies two compiler flags:
31+
TL;DR: `//@ add-minicore` implies two compiler flags:
3232

3333
1. `-C panic=abort`
3434
2. `-C force-unwind-tables=yes`
@@ -48,7 +48,7 @@ attributes (e.g. `on_unimplemented`) should be replicated exactly in `minicore`.
4848
## Example codegen test that uses `minicore`
4949

5050
```rust,no_run
51-
//@ add-core-stubs
51+
//@ add-minicore
5252
//@ revisions: meow bark
5353
//@[meow] compile-flags: --target=x86_64-unknown-linux-gnu
5454
//@[meow] needs-llvm-components: x86

src/tools/compiletest/src/directives.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ pub(crate) struct TestProps {
200200
pub no_auto_check_cfg: bool,
201201
/// Build and use `minicore` as `core` stub for `no_core` tests in cross-compilation scenarios
202202
/// that don't otherwise want/need `-Z build-std`.
203-
pub add_core_stubs: bool,
203+
pub add_minicore: bool,
204204
/// Add these flags to the build of `minicore`.
205-
pub core_stubs_compile_flags: Vec<String>,
205+
pub minicore_compile_flags: Vec<String>,
206206
/// Whether line annotatins are required for the given error kind.
207207
pub dont_require_annotations: HashSet<ErrorKind>,
208208
/// Whether pretty printers should be disabled in gdb.
@@ -254,8 +254,8 @@ mod directives {
254254
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
255255
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
256256
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
257-
pub const ADD_CORE_STUBS: &'static str = "add-core-stubs";
258-
pub const CORE_STUBS_COMPILE_FLAGS: &'static str = "core-stubs-compile-flags";
257+
pub const ADD_MINICORE: &'static str = "add-minicore";
258+
pub const MINICORE_COMPILE_FLAGS: &'static str = "minicore-compile-flags";
259259
pub const DISABLE_GDB_PRETTY_PRINTERS: &'static str = "disable-gdb-pretty-printers";
260260
pub const COMPARE_OUTPUT_BY_LINES: &'static str = "compare-output-by-lines";
261261
}
@@ -311,8 +311,8 @@ impl TestProps {
311311
llvm_cov_flags: vec![],
312312
filecheck_flags: vec![],
313313
no_auto_check_cfg: false,
314-
add_core_stubs: false,
315-
core_stubs_compile_flags: vec![],
314+
add_minicore: false,
315+
minicore_compile_flags: vec![],
316316
dont_require_annotations: Default::default(),
317317
disable_gdb_pretty_printers: false,
318318
compare_output_by_lines: false,
@@ -601,18 +601,18 @@ impl TestProps {
601601

602602
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
603603

604-
self.update_add_core_stubs(ln, config);
604+
self.update_add_minicore(ln, config);
605605

606606
if let Some(flags) =
607-
config.parse_name_value_directive(ln, CORE_STUBS_COMPILE_FLAGS)
607+
config.parse_name_value_directive(ln, MINICORE_COMPILE_FLAGS)
608608
{
609609
let flags = split_flags(&flags);
610610
for flag in &flags {
611611
if flag == "--edition" || flag.starts_with("--edition=") {
612612
panic!("you must use `//@ edition` to configure the edition");
613613
}
614614
}
615-
self.core_stubs_compile_flags.extend(flags);
615+
self.minicore_compile_flags.extend(flags);
616616
}
617617

618618
if let Some(err_kind) =
@@ -753,12 +753,12 @@ impl TestProps {
753753
self.pass_mode
754754
}
755755

756-
fn update_add_core_stubs(&mut self, ln: &DirectiveLine<'_>, config: &Config) {
757-
let add_core_stubs = config.parse_name_directive(ln, directives::ADD_CORE_STUBS);
758-
if add_core_stubs {
756+
fn update_add_minicore(&mut self, ln: &DirectiveLine<'_>, config: &Config) {
757+
let add_minicore = config.parse_name_directive(ln, directives::ADD_MINICORE);
758+
if add_minicore {
759759
if !matches!(config.mode, TestMode::Ui | TestMode::Codegen | TestMode::Assembly) {
760760
panic!(
761-
"`add-core-stubs` is currently only supported for ui, codegen and assembly test modes"
761+
"`add-minicore` is currently only supported for ui, codegen and assembly test modes"
762762
);
763763
}
764764

@@ -767,10 +767,10 @@ impl TestProps {
767767
if self.local_pass_mode().is_some_and(|pm| pm == PassMode::Run) {
768768
// `minicore` can only be used with non-run modes, because it's `core` prelude stubs
769769
// and can't run.
770-
panic!("`add-core-stubs` cannot be used to run the test binary");
770+
panic!("`add-minicore` cannot be used to run the test binary");
771771
}
772772

773-
self.add_core_stubs = add_core_stubs;
773+
self.add_minicore = add_minicore;
774774
}
775775
}
776776
}

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// a best-effort approximation for diagnostics. Add new directives to this list when needed.
44
pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
55
// tidy-alphabetical-start
6-
"add-core-stubs",
6+
"add-minicore",
77
"assembly-output",
88
"aux-bin",
99
"aux-build",
@@ -19,7 +19,6 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
1919
"check-test-line-numbers-match",
2020
"compare-output-by-lines",
2121
"compile-flags",
22-
"core-stubs-compile-flags",
2322
"disable-gdb-pretty-printers",
2423
"doc-flags",
2524
"dont-check-compiler-stderr",
@@ -141,6 +140,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
141140
"min-lldb-version",
142141
"min-llvm-version",
143142
"min-system-llvm-version",
143+
"minicore-compile-flags",
144144
"needs-asm-support",
145145
"needs-backends",
146146
"needs-crate-type",

src/tools/compiletest/src/runtest.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ impl<'test> TestCx<'test> {
13071307
/// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an
13081308
/// aux-build have the same `root_testpaths`.
13091309
fn compose_and_run_compiler(&self, mut rustc: Command, input: Option<String>) -> ProcRes {
1310-
if self.props.add_core_stubs {
1310+
if self.props.add_minicore {
13111311
let minicore_path = self.build_minicore();
13121312
rustc.arg("--extern");
13131313
rustc.arg(&format!("minicore={}", minicore_path));
@@ -1341,7 +1341,7 @@ impl<'test> TestCx<'test> {
13411341

13421342
rustc.args(&["--crate-type", "rlib"]);
13431343
rustc.arg("-Cpanic=abort");
1344-
rustc.args(self.props.core_stubs_compile_flags.clone());
1344+
rustc.args(self.props.minicore_compile_flags.clone());
13451345

13461346
let res = self.compose_and_run(rustc, self.config.compile_lib_path.as_path(), None, None);
13471347
if !res.status.success() {
@@ -1449,7 +1449,7 @@ impl<'test> TestCx<'test> {
14491449

14501450
aux_rustc.arg("-L").arg(&aux_dir);
14511451

1452-
if aux_props.add_core_stubs {
1452+
if aux_props.add_minicore {
14531453
let minicore_path = self.build_minicore();
14541454
aux_rustc.arg("--extern");
14551455
aux_rustc.arg(&format!("minicore={}", minicore_path));
@@ -1891,7 +1891,7 @@ impl<'test> TestCx<'test> {
18911891
// change the default.
18921892
//
18931893
// `minicore` requires `#![no_std]` and `#![no_core]`, which means no unwinding panics.
1894-
if self.props.add_core_stubs {
1894+
if self.props.add_minicore {
18951895
rustc.arg("-Cpanic=abort");
18961896
rustc.arg("-Cforce-unwind-tables=yes");
18971897
}

tests/assembly-llvm/aarch64-pointer-auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Test that PAC instructions are emitted when branch-protection is specified.
22

3-
//@ add-core-stubs
3+
//@ add-minicore
44
//@ revisions: GCS PACRET PAUTHLR_NOP PAUTHLR
55
//@ assembly-output: emit-asm
66
//@ needs-llvm-components: aarch64

tests/assembly-llvm/asm/aarch64-el2vmsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ add-core-stubs
1+
//@ add-minicore
22
//@ assembly-output: emit-asm
33
//@ compile-flags: --target aarch64-unknown-linux-gnu
44
//@ needs-llvm-components: aarch64

tests/assembly-llvm/asm/aarch64-modifiers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ add-core-stubs
1+
//@ add-minicore
22
//@ assembly-output: emit-asm
33
//@ compile-flags: -Copt-level=3 -C panic=abort
44
//@ compile-flags: --target aarch64-unknown-linux-gnu

tests/assembly-llvm/asm/aarch64-types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ add-core-stubs
1+
//@ add-minicore
22
//@ revisions: aarch64 arm64ec
33
//@ assembly-output: emit-asm
44
//@ [aarch64] compile-flags: --target aarch64-unknown-linux-gnu

tests/assembly-llvm/asm/arm-modifiers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ add-core-stubs
1+
//@ add-minicore
22
//@ assembly-output: emit-asm
33
//@ compile-flags: -Copt-level=3 -C panic=abort
44
//@ compile-flags: --target armv7-unknown-linux-gnueabihf

tests/assembly-llvm/asm/arm-types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ add-core-stubs
1+
//@ add-minicore
22
//@ revisions: base d32 neon
33
//@ assembly-output: emit-asm
44
//@ compile-flags: --target armv7-unknown-linux-gnueabihf

0 commit comments

Comments
 (0)