Skip to content

Commit

Permalink
Don't allow -Zunstable-options to take a value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Zalathar committed Nov 18, 2024
1 parent 0a619dd commit 660246b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 1 deletion compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2171,8 +2171,14 @@ written to standard error output)"),
"enable unsound and buggy MIR optimizations (default: no)"),
/// This name is kind of confusing: Most unstable options enable something themselves, while
/// this just allows "normal" options to be feature-gated.
///
/// The main check for `-Zunstable-options` takes place separately from the
/// usual parsing of `-Z` options (see [`crate::config::nightly_options`]),
/// so this boolean value is mostly used for enabling unstable _values_ of
/// stable options. That separate check doesn't handle boolean values, so
/// to avoid an inconsistent state we also forbid them here.
#[rustc_lint_opt_deny_field_access("use `Session::unstable_options` instead of this field")]
unstable_options: bool = (false, parse_bool, [UNTRACKED],
unstable_options: bool = (false, parse_no_value, [UNTRACKED],
"adds unstable command line options to rustc interface (default: no)"),
use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
"use legacy .ctors section for initializers rather than .init_array"),
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/codemap_tests/huge_multispan_highlight.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ revisions: ascii unicode
//@ compile-flags: --color=always
//@[ascii] compile-flags: --error-format=human
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode
//@ ignore-windows
fn main() {
let _ = match true {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/diagnostic-width/E0271.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ revisions: ascii unicode
//@[ascii] compile-flags: --diagnostic-width=40
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode --diagnostic-width=40
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode --diagnostic-width=40
//@ normalize-stderr-test: "long-type-\d+" -> "long-type-hash"
trait Future {
type Error;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/diagnostic-width/flag-human.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ revisions: ascii unicode
//@[ascii] compile-flags: --diagnostic-width=20
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode --diagnostic-width=20
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode --diagnostic-width=20

// This test checks that `-Z output-width` effects the human error output by restricting it to an
// arbitrarily low value so that the effect is visible.
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/diagnostic-width/long-E0308.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ revisions: ascii unicode
//@[ascii] compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
//@[unicode] compile-flags: -Zunstable-options=yes --json=diagnostic-unicode --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
//@[unicode] compile-flags: -Zunstable-options --json=diagnostic-unicode --diagnostic-width=60 -Zwrite-long-types-to-disk=yes
//@ normalize-stderr-test: "long-type-\d+" -> "long-type-hash"

mod a {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ revisions: ascii unicode
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode
// ignore-tidy-linelength

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/diagnostic-width/non-whitespace-trimming-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ revisions: ascii unicode
//@[unicode] compile-flags: -Zunstable-options=yes --error-format=human-unicode
//@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode
// ignore-tidy-linelength

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-emitter/unicode-output.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ compile-flags: -Zunstable-options=yes --error-format=human-unicode --color=always
//@ compile-flags: -Zunstable-options --error-format=human-unicode --color=always
//@ edition:2018
//@ only-linux

Expand Down

0 comments on commit 660246b

Please sign in to comment.