Skip to content

Commit 7d8d712

Browse files
committed
Add a ui test for RUSTC_BOOTSTRAP vs rustc's stability
1 parent 9849d6f commit 7d8d712

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: the option `Z` is only accepted on the nightly compiler
2+
3+
help: consider switching to a nightly toolchain: `rustup default nightly`
4+
5+
note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>
6+
7+
note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>
8+
9+
error: 1 nightly option were parsed
10+

tests/ui/bootstrap/rustc_bootstap.rs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//! Check `RUSTC_BOOTSTRAP`'s behavior in relation to feature stability and what rustc considers
2+
//! itself to be (stable vs non-stable ).
3+
//!
4+
//! `RUSTC_BOOTSTRAP` accepts:
5+
//!
6+
//! - `1`: cheat, allow usage of unstable features even if rustc thinks it is a stable compiler.
7+
//! - `x,y,z`: comma-delimited list of crates, basically allow unstable features for specific
8+
//! crates, this is for use by cargo.
9+
//! - `-1`: force rustc to think it is a stable compiler.
10+
11+
// ignore-tidy-linelength
12+
13+
//@ revisions: default_nightly cheat cheat_single_crate cheat_multi_crate force_stable invalid_zero invalid_junk
14+
//@ only-nightly
15+
16+
//@[default_nightly] unset-rustc-env:RUSTC_BOOTSTRAP
17+
//@[default_nightly] check-pass
18+
19+
// For a nightly compiler, this is same as `default_nightly` as if `RUSTC_BOOTSTRAP` was unset.
20+
//@[invalid_zero] rustc-env:RUSTC_BOOTSTRAP=0
21+
//@[invalid_zero] check-pass
22+
23+
// Invalid values are silently discarded, same as `default_nightly`, i.e. as if `RUSTC_BOOTSTRAP`
24+
// was unset.
25+
//@[invalid_junk] rustc-env:RUSTC_BOOTSTRAP=*
26+
//@[invalid_junk] check-pass
27+
28+
//@[cheat] rustc-env:RUSTC_BOOTSTRAP=1
29+
//@[cheat] check-pass
30+
31+
//@[cheat_single_crate] rustc-env:RUSTC_BOOTSTRAP=x
32+
//@[cheat_single_crate] check-pass
33+
34+
//@[cheat_multi_crate] rustc-env:RUSTC_BOOTSTRAP=x,y,z
35+
//@[cheat_multi_crate] check-pass
36+
37+
// Note: compiletest passes some `-Z` flags to the compiler for ui testing purposes, so here we
38+
// instead abuse the fact that `-Z unstable-options` is also part of rustc's stability story and is
39+
// also affected by `RUSTC_BOOTSTRAP`.
40+
//@[force_stable] rustc-env:RUSTC_BOOTSTRAP=-1
41+
//@[force_stable] compile-flags: -Z unstable-options
42+
//@[force_stable] regex-error-pattern: error: the option `Z` is only accepted on the nightly compiler
43+
44+
#![crate_type = "lib"]
45+
46+
// Note: `rustc_attrs` is a perma-unstable internal feature that is unlikely to change, which is
47+
// used as a proxy to check `RUSTC_BOOTSTRAP` versus stability checking logic.
48+
#![feature(rustc_attrs)]

0 commit comments

Comments
 (0)