Skip to content

Commit 0a619dd

Browse files
committed
Rename parse_no_flag to parse_no_value
The old name and comment suggest that this parser is only used for options beginning with `no-`, which is mostly true but not entirely true.
1 parent 5ec7d6e commit 0a619dd

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

compiler/rustc_session/src/options.rs

+22-18
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn build_options<O: Default>(
358358

359359
#[allow(non_upper_case_globals)]
360360
mod desc {
361-
pub(crate) const parse_no_flag: &str = "no value";
361+
pub(crate) const parse_no_value: &str = "no value";
362362
pub(crate) const parse_bool: &str =
363363
"one of: `y`, `yes`, `on`, `true`, `n`, `no`, `off` or `false`";
364364
pub(crate) const parse_opt_bool: &str = parse_bool;
@@ -462,14 +462,18 @@ pub mod parse {
462462
pub(crate) use super::*;
463463
pub(crate) const MAX_THREADS_CAP: usize = 256;
464464

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 {
468471
match v {
469472
None => {
470473
*slot = true;
471474
true
472475
}
476+
// Trying to specify a value is always forbidden.
473477
Some(_) => false,
474478
}
475479
}
@@ -1609,16 +1613,16 @@ options! {
16091613
"perform LLVM link-time optimizations"),
16101614
metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
16111615
"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],
16131617
"give an empty list of passes to the pass manager"),
16141618
no_redzone: Option<bool> = (None, parse_opt_bool, [TRACKED],
16151619
"disable the use of the redzone"),
16161620
#[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],
16181622
"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],
16201624
"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],
16221626
"disable LLVM's SLP vectorization pass"),
16231627
opt_level: String = ("0".to_string(), parse_string, [TRACKED],
16241628
"optimization level (0-3, s, or z; default: 0)"),
@@ -1917,25 +1921,25 @@ options! {
19171921
"dump facts from NLL analysis into side files (default: no)"),
19181922
nll_facts_dir: String = ("nll-facts".to_string(), parse_string, [UNTRACKED],
19191923
"the directory the NLL facts are dumped into (default: `nll-facts`)"),
1920-
no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
1924+
no_analysis: bool = (false, parse_no_value, [UNTRACKED],
19211925
"parse and expand the source, but run no analysis"),
1922-
no_codegen: bool = (false, parse_no_flag, [TRACKED_NO_CRATE_HASH],
1926+
no_codegen: bool = (false, parse_no_value, [TRACKED_NO_CRATE_HASH],
19231927
"run all passes except codegen; no output"),
1924-
no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
1928+
no_generate_arange_section: bool = (false, parse_no_value, [TRACKED],
19251929
"omit DWARF address ranges that give faster lookups"),
19261930
no_implied_bounds_compat: bool = (false, parse_bool, [TRACKED],
19271931
"disable the compatibility version of the `implied_bounds_ty` query"),
1928-
no_jump_tables: bool = (false, parse_no_flag, [TRACKED],
1932+
no_jump_tables: bool = (false, parse_no_value, [TRACKED],
19291933
"disable the jump tables and lookup tables that can be generated from a switch case lowering"),
1930-
no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
1934+
no_leak_check: bool = (false, parse_no_value, [UNTRACKED],
19311935
"disable the 'leak check' for subtyping; unsound, but useful for tests"),
1932-
no_link: bool = (false, parse_no_flag, [TRACKED],
1936+
no_link: bool = (false, parse_no_value, [TRACKED],
19331937
"compile without linking"),
1934-
no_parallel_backend: bool = (false, parse_no_flag, [UNTRACKED],
1938+
no_parallel_backend: bool = (false, parse_no_value, [UNTRACKED],
19351939
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
1936-
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
1940+
no_profiler_runtime: bool = (false, parse_no_value, [TRACKED],
19371941
"prevent automatic injection of the profiler_builtins crate"),
1938-
no_trait_vptr: bool = (false, parse_no_flag, [TRACKED],
1942+
no_trait_vptr: bool = (false, parse_no_value, [TRACKED],
19391943
"disable generation of trait vptr in vtable for upcasting"),
19401944
no_unique_section_names: bool = (false, parse_bool, [TRACKED],
19411945
"do not use unique names for text and data sections when -Z function-sections is used"),
@@ -1993,7 +1997,7 @@ options! {
19931997
proc_macro_execution_strategy: ProcMacroExecutionStrategy = (ProcMacroExecutionStrategy::SameThread,
19941998
parse_proc_macro_execution_strategy, [UNTRACKED],
19951999
"how to run proc-macro code (default: same-thread)"),
1996-
profile_closures: bool = (false, parse_no_flag, [UNTRACKED],
2000+
profile_closures: bool = (false, parse_no_value, [UNTRACKED],
19972001
"profile size of closures"),
19982002
profile_sample_use: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
19992003
"use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),

0 commit comments

Comments
 (0)