Skip to content

Commit 660246b

Browse files
committed
Don't allow -Zunstable-options to take a value
Passing an explicit boolean value (`on`, `off` etc.) appears to work, but actually puts the compiler into an unintended state where unstable _options_ are still forbidden, but unstable values of _some_ stable options are allowed.
1 parent 0a619dd commit 660246b

File tree

8 files changed

+14
-8
lines changed

8 files changed

+14
-8
lines changed

compiler/rustc_session/src/options.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2171,8 +2171,14 @@ written to standard error output)"),
21712171
"enable unsound and buggy MIR optimizations (default: no)"),
21722172
/// This name is kind of confusing: Most unstable options enable something themselves, while
21732173
/// this just allows "normal" options to be feature-gated.
2174+
///
2175+
/// The main check for `-Zunstable-options` takes place separately from the
2176+
/// usual parsing of `-Z` options (see [`crate::config::nightly_options`]),
2177+
/// so this boolean value is mostly used for enabling unstable _values_ of
2178+
/// stable options. That separate check doesn't handle boolean values, so
2179+
/// to avoid an inconsistent state we also forbid them here.
21742180
#[rustc_lint_opt_deny_field_access("use `Session::unstable_options` instead of this field")]
2175-
unstable_options: bool = (false, parse_bool, [UNTRACKED],
2181+
unstable_options: bool = (false, parse_no_value, [UNTRACKED],
21762182
"adds unstable command line options to rustc interface (default: no)"),
21772183
use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
21782184
"use legacy .ctors section for initializers rather than .init_array"),

tests/ui/codemap_tests/huge_multispan_highlight.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ revisions: ascii unicode
22
//@ compile-flags: --color=always
33
//@[ascii] compile-flags: --error-format=human
4-
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
4+
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode
55
//@ ignore-windows
66
fn main() {
77
let _ = match true {

tests/ui/diagnostic-width/E0271.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ revisions: ascii unicode
22
//@[ascii] compile-flags: --diagnostic-width=40
3-
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode --diagnostic-width=40
3+
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode --diagnostic-width=40
44
//@ normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
55
trait Future {
66
type Error;

tests/ui/diagnostic-width/flag-human.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ revisions: ascii unicode
22
//@[ascii] compile-flags: --diagnostic-width=20
3-
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode --diagnostic-width=20
3+
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode --diagnostic-width=20
44

55
// This test checks that `-Z output-width` effects the human error output by restricting it to an
66
// arbitrarily low value so that the effect is visible.

tests/ui/diagnostic-width/long-E0308.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ revisions: ascii unicode
22
//@[ascii] compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
3-
//@[unicode] compile-flags: -Zunstable-options=yes --json=diagnostic-unicode --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
3+
//@[unicode] compile-flags: -Zunstable-options --json=diagnostic-unicode --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
44
//@ normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
55

66
mod a {

tests/ui/diagnostic-width/non-1-width-unicode-multiline-label.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ revisions: ascii unicode
2-
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
2+
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode
33
// ignore-tidy-linelength
44

55
fn main() {

tests/ui/diagnostic-width/non-whitespace-trimming-2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ revisions: ascii unicode
2-
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
2+
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode
33
// ignore-tidy-linelength
44

55
fn main() {

tests/ui/error-emitter/unicode-output.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Zunstable-options=yes --error-format=human-unicode --color=always
1+
//@ compile-flags: -Zunstable-options --error-format=human-unicode --color=always
22
//@ edition:2018
33
//@ only-linux
44

0 commit comments

Comments
 (0)