@@ -358,7 +358,7 @@ fn build_options<O: Default>(
358
358
359
359
#[ allow( non_upper_case_globals) ]
360
360
mod desc {
361
- pub ( crate ) const parse_no_flag : & str = "no value" ;
361
+ pub ( crate ) const parse_no_value : & str = "no value" ;
362
362
pub ( crate ) const parse_bool: & str =
363
363
"one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`" ;
364
364
pub ( crate ) const parse_opt_bool: & str = parse_bool;
@@ -462,14 +462,18 @@ pub mod parse {
462
462
pub ( crate ) use super :: * ;
463
463
pub ( crate ) const MAX_THREADS_CAP : usize = 256 ;
464
464
465
- /// This is for boolean options that don't take a value and start with
466
- /// `no-`. This style of option is deprecated.
467
- pub ( crate ) fn parse_no_flag ( slot : & mut bool , v : Option < & str > ) -> bool {
465
+ /// This is for boolean options that don't take a value, and are true simply
466
+ /// by existing on the command-line.
467
+ ///
468
+ /// This style of option is deprecated, and is mainly used by old options
469
+ /// beginning with `no-`.
470
+ pub ( crate ) fn parse_no_value ( slot : & mut bool , v : Option < & str > ) -> bool {
468
471
match v {
469
472
None => {
470
473
* slot = true ;
471
474
true
472
475
}
476
+ // Trying to specify a value is always forbidden.
473
477
Some ( _) => false ,
474
478
}
475
479
}
@@ -1609,16 +1613,16 @@ options! {
1609
1613
"perform LLVM link-time optimizations" ) ,
1610
1614
metadata: Vec <String > = ( Vec :: new( ) , parse_list, [ TRACKED ] ,
1611
1615
"metadata to mangle symbol names with" ) ,
1612
- no_prepopulate_passes: bool = ( false , parse_no_flag , [ TRACKED ] ,
1616
+ no_prepopulate_passes: bool = ( false , parse_no_value , [ TRACKED ] ,
1613
1617
"give an empty list of passes to the pass manager" ) ,
1614
1618
no_redzone: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
1615
1619
"disable the use of the redzone" ) ,
1616
1620
#[ rustc_lint_opt_deny_field_access( "documented to do nothing" ) ]
1617
- no_stack_check: bool = ( false , parse_no_flag , [ UNTRACKED ] ,
1621
+ no_stack_check: bool = ( false , parse_no_value , [ UNTRACKED ] ,
1618
1622
"this option is deprecated and does nothing" ) ,
1619
- no_vectorize_loops: bool = ( false , parse_no_flag , [ TRACKED ] ,
1623
+ no_vectorize_loops: bool = ( false , parse_no_value , [ TRACKED ] ,
1620
1624
"disable loop vectorization optimization passes" ) ,
1621
- no_vectorize_slp: bool = ( false , parse_no_flag , [ TRACKED ] ,
1625
+ no_vectorize_slp: bool = ( false , parse_no_value , [ TRACKED ] ,
1622
1626
"disable LLVM's SLP vectorization pass" ) ,
1623
1627
opt_level: String = ( "0" . to_string( ) , parse_string, [ TRACKED ] ,
1624
1628
"optimization level (0-3, s, or z; default: 0)" ) ,
@@ -1915,25 +1919,25 @@ options! {
1915
1919
"dump facts from NLL analysis into side files (default: no)" ) ,
1916
1920
nll_facts_dir: String = ( "nll-facts" . to_string( ) , parse_string, [ UNTRACKED ] ,
1917
1921
"the directory the NLL facts are dumped into (default: `nll-facts`)" ) ,
1918
- no_analysis: bool = ( false , parse_no_flag , [ UNTRACKED ] ,
1922
+ no_analysis: bool = ( false , parse_no_value , [ UNTRACKED ] ,
1919
1923
"parse and expand the source, but run no analysis" ) ,
1920
- no_codegen: bool = ( false , parse_no_flag , [ TRACKED_NO_CRATE_HASH ] ,
1924
+ no_codegen: bool = ( false , parse_no_value , [ TRACKED_NO_CRATE_HASH ] ,
1921
1925
"run all passes except codegen; no output" ) ,
1922
- no_generate_arange_section: bool = ( false , parse_no_flag , [ TRACKED ] ,
1926
+ no_generate_arange_section: bool = ( false , parse_no_value , [ TRACKED ] ,
1923
1927
"omit DWARF address ranges that give faster lookups" ) ,
1924
1928
no_implied_bounds_compat: bool = ( false , parse_bool, [ TRACKED ] ,
1925
1929
"disable the compatibility version of the `implied_bounds_ty` query" ) ,
1926
- no_jump_tables: bool = ( false , parse_no_flag , [ TRACKED ] ,
1930
+ no_jump_tables: bool = ( false , parse_no_value , [ TRACKED ] ,
1927
1931
"disable the jump tables and lookup tables that can be generated from a switch case lowering" ) ,
1928
- no_leak_check: bool = ( false , parse_no_flag , [ UNTRACKED ] ,
1932
+ no_leak_check: bool = ( false , parse_no_value , [ UNTRACKED ] ,
1929
1933
"disable the 'leak check' for subtyping; unsound, but useful for tests" ) ,
1930
- no_link: bool = ( false , parse_no_flag , [ TRACKED ] ,
1934
+ no_link: bool = ( false , parse_no_value , [ TRACKED ] ,
1931
1935
"compile without linking" ) ,
1932
- no_parallel_backend: bool = ( false , parse_no_flag , [ UNTRACKED ] ,
1936
+ no_parallel_backend: bool = ( false , parse_no_value , [ UNTRACKED ] ,
1933
1937
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)" ) ,
1934
- no_profiler_runtime: bool = ( false , parse_no_flag , [ TRACKED ] ,
1938
+ no_profiler_runtime: bool = ( false , parse_no_value , [ TRACKED ] ,
1935
1939
"prevent automatic injection of the profiler_builtins crate" ) ,
1936
- no_trait_vptr: bool = ( false , parse_no_flag , [ TRACKED ] ,
1940
+ no_trait_vptr: bool = ( false , parse_no_value , [ TRACKED ] ,
1937
1941
"disable generation of trait vptr in vtable for upcasting" ) ,
1938
1942
no_unique_section_names: bool = ( false , parse_bool, [ TRACKED ] ,
1939
1943
"do not use unique names for text and data sections when -Z function-sections is used" ) ,
@@ -1991,7 +1995,7 @@ options! {
1991
1995
proc_macro_execution_strategy: ProcMacroExecutionStrategy = ( ProcMacroExecutionStrategy :: SameThread ,
1992
1996
parse_proc_macro_execution_strategy, [ UNTRACKED ] ,
1993
1997
"how to run proc-macro code (default: same-thread)" ) ,
1994
- profile_closures: bool = ( false , parse_no_flag , [ UNTRACKED ] ,
1998
+ profile_closures: bool = ( false , parse_no_value , [ UNTRACKED ] ,
1995
1999
"profile size of closures" ) ,
1996
2000
profile_sample_use: Option <PathBuf > = ( None , parse_opt_pathbuf, [ TRACKED ] ,
1997
2001
"use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)" ) ,
@@ -2165,8 +2169,14 @@ written to standard error output)"),
2165
2169
"enable unsound and buggy MIR optimizations (default: no)" ) ,
2166
2170
/// This name is kind of confusing: Most unstable options enable something themselves, while
2167
2171
/// this just allows "normal" options to be feature-gated.
2172
+ ///
2173
+ /// The main check for `-Zunstable-options` takes place separately from the
2174
+ /// usual parsing of `-Z` options (see [`crate::config::nightly_options`]),
2175
+ /// so this boolean value is mostly used for enabling unstable _values_ of
2176
+ /// stable options. That separate check doesn't handle boolean values, so
2177
+ /// to avoid an inconsistent state we also forbid them here.
2168
2178
#[ rustc_lint_opt_deny_field_access( "use `Session::unstable_options` instead of this field" ) ]
2169
- unstable_options: bool = ( false , parse_bool , [ UNTRACKED ] ,
2179
+ unstable_options: bool = ( false , parse_no_value , [ UNTRACKED ] ,
2170
2180
"adds unstable command line options to rustc interface (default: no)" ) ,
2171
2181
use_ctors_section: Option <bool > = ( None , parse_opt_bool, [ TRACKED ] ,
2172
2182
"use legacy .ctors section for initializers rather than .init_array" ) ,
0 commit comments