Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b679e71

Browse files
authoredNov 18, 2024
Mention RUSTC_BOOTSTRAP for misc testing (#2136)
1 parent da53251 commit b679e71

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed
 

‎src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [Rust for Linux](./tests/rust-for-linux.md)
3333
- [Performance testing](./tests/perf.md)
3434
- [Suggest tests tool](./tests/suggest-tests.md)
35+
- [Misc info](./tests/misc.md)
3536
- [Debugging the compiler](./compiler-debugging.md)
3637
- [Using the tracing/logging instrumentation](./tracing.md)
3738
- [Profiling the compiler](./profiling.md)

‎src/tests/intro.md

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ chapter](ecosystem.md) for more details.
155155
A separate infrastructure is used for testing and tracking performance of the
156156
compiler. See the [Performance testing chapter](perf.md) for more details.
157157

158+
## Miscellaneous information
159+
160+
There are some other useful testing-related info at [Misc info](misc.md).
161+
158162
## Further reading
159163

160164
The following blog posts may also be of interest:

‎src/tests/misc.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Miscellaneous testing-related info
2+
3+
## `RUSTC_BOOTSTRAP` and stability
4+
5+
<!-- date-check: Nov 2024 -->
6+
7+
This is a bootstrap/compiler implementation detail, but it can also be useful
8+
for testing:
9+
10+
- `RUSTC_BOOTSTRAP=1` will "cheat" and bypass usual stability checking, allowing
11+
you to use unstable features and cli flags on a stable `rustc`.
12+
- `RUSTC_BOOTSTRAP=-1` will force a given `rustc` to pretend that is a stable
13+
compiler, even if it's actually a nightly `rustc`. This is useful because some
14+
behaviors of the compiler (e.g. diagnostics) can differ depending on whether
15+
the compiler is nightly or not.
16+
17+
In `ui` tests and other test suites that support `//@ rustc-env`, you can specify
18+
19+
```rust,ignore
20+
// Force unstable features to be usable on stable rustc
21+
//@ rustc-env:RUSTC_BOOTSTRAP=1
22+
23+
// Or force nightly rustc to pretend it is a stable rustc
24+
//@ rustc-env:RUSTC_BOOTSTRAP=-1
25+
```
26+
27+
For `run-make` tests, `//@ rustc-env` is not supported. You can do something
28+
like the following for individual `rustc` invocations.
29+
30+
```rust,ignore
31+
use run_make_support::rustc;
32+
33+
fn main() {
34+
rustc()
35+
// Pretend that I am very stable
36+
.env("RUSTC_BOOTSTRAP", "-1")
37+
//...
38+
.run();
39+
}
40+
```

0 commit comments

Comments
 (0)
Please sign in to comment.