|
| 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. |
| 8 | +//! - `-1`: force rustc to think it is a stable compiler. |
| 9 | +
|
| 10 | +// ignore-tidy-linelength |
| 11 | + |
| 12 | +//@ revisions: default_nightly cheat cheat_single_crate cheat_multi_crate force_stable invalid_zero invalid_junk |
| 13 | +//@ only-nightly |
| 14 | + |
| 15 | +//@[default_nightly] unset-rustc-env:RUSTC_BOOTSTRAP |
| 16 | +//@[default_nightly] check-pass |
| 17 | + |
| 18 | +// For a nightly compiler, this is same as `default_nightly` as if `RUSTC_BOOTSTRAP` was unset. |
| 19 | +//@[invalid_zero] rustc-env:RUSTC_BOOTSTRAP=0 |
| 20 | +//@[invalid_zero] check-pass |
| 21 | + |
| 22 | +// Invalid values are silently discarded, same as `default_nightly`, i.e. as if `RUSTC_BOOTSTRAP` |
| 23 | +// was unset. |
| 24 | +//@[invalid_junk] rustc-env:RUSTC_BOOTSTRAP=* |
| 25 | +//@[invalid_junk] check-pass |
| 26 | + |
| 27 | +//@[cheat] rustc-env:RUSTC_BOOTSTRAP=1 |
| 28 | +//@[cheat] check-pass |
| 29 | + |
| 30 | +//@[cheat_single_crate] rustc-env:RUSTC_BOOTSTRAP=x |
| 31 | +//@[cheat_single_crate] check-pass |
| 32 | + |
| 33 | +//@[cheat_multi_crate] rustc-env:RUSTC_BOOTSTRAP=x,y,z |
| 34 | +//@[cheat_multi_crate] check-pass |
| 35 | + |
| 36 | +// Note: compiletest passes some `-Z` flags to the compiler for ui testing purposes, so here we |
| 37 | +// instead abuse the fact that `-Z unstable-options` is also part of rustc's stability story and is |
| 38 | +// also affected by `RUSTC_BOOTSTRAP`. |
| 39 | +//@[force_stable] rustc-env:RUSTC_BOOTSTRAP=-1 |
| 40 | +//@[force_stable] compile-flags: -Z unstable-options |
| 41 | +//@[force_stable] regex-error-pattern: error: the option `Z` is only accepted on the nightly compiler |
| 42 | + |
| 43 | +#![crate_type = "lib"] |
| 44 | + |
| 45 | +// Note: `rustc_attrs` is a perma-unstable internal feature that is unlikely to change, which is |
| 46 | +// used as a proxy to check `RUSTC_BOOTSTRAP` versus stability checking logic. |
| 47 | +#![feature(rustc_attrs)] |
0 commit comments