about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2020-04-06 09:29:19 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2020-04-19 20:05:23 +1000
commit3e3fd73f85c8dd2a7ba6b2072bfb1158e7e6872f (patch)
tree614b88e0bc6f933e105e27cf009df2f3635f13fe /src
parentdc0653987215293d239bfc9fd6623a4b1d6fbc36 (diff)
downloadrust-3e3fd73f85c8dd2a7ba6b2072bfb1158e7e6872f.tar.gz
rust-3e3fd73f85c8dd2a7ba6b2072bfb1158e7e6872f.zip
Disallow values for `-C no-*` and `-Z no-*` options again.
With the exception of `-C no-redzone`, because that could take a value
before this PR.

This partially undoes one of the earlier commits in this PR, which added
the ability to take a value to all boolean options that lacked it.

The help output for these options looks like this:
```
    -C         no-vectorize-slp=val -- disable LLVM's SLP vectorization pass
```
The "=val" part is a lie, but hopefully this will be fixed in the future.
Diffstat (limited to 'src')
-rw-r--r--src/doc/rustc/src/codegen-options/index.md23
-rw-r--r--src/librustc_session/options.rs58
2 files changed, 40 insertions, 41 deletions
diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md
index 22cdc9f2339..5dda5ec2cb8 100644
--- a/src/doc/rustc/src/codegen-options/index.md
+++ b/src/doc/rustc/src/codegen-options/index.md
@@ -180,30 +180,19 @@ If not specified, overflow checks are enabled if
 
 ## no-prepopulate-passes
 
-This flag controls whether the pass manager uses a pre-populated list of
-passes. It takes one of the following values:
-
-* `y`, `yes`, `on`, or no value: use an empty list of passes.
-* `n`, `no`, or `off`: use a pre-populated list of passes (the default).
+This flag tells the pass manager to use an empty list of passes, instead of the
+usual pre-populated list of passes.
 
 ## no-vectorize-loops
 
-This flag controls whether `rustc` will attempt to [vectorize
-loops](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer). It takes
-one of the following values:
-
-* `y`, `yes`, `on`, or no value: disable loop vectorization.
-* `n`, `no`, or `off`: enable loop vectorization (the default).
+This flag disables [loop
+vectorization](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer).
 
 ## no-vectorize-slp
 
-This flag controls whether `rustc` will attempt to vectorize code using
+This flag disables vectorization using
 [superword-level
 parallelism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer).
-It takes one of the following values:
-
-* `y`, `yes`, `on`, or no value: disable SLP vectorization.
-* `n`, `no`, or `off`: enable SLP vectorization (the default).
 
 ## soft-float
 
@@ -309,7 +298,7 @@ This flag controls the optimization level.
 * `2`: some optimizations.
 * `3`: all optimizations.
 * `s`: optimize for binary size.
-* `z`: optimize for binary size, but also turn off loop vectorization..
+* `z`: optimize for binary size, but also turn off loop vectorization.
 
 Note: The [`-O` flag][option-o-optimize] is an alias for `-C opt-level=2`.
 
diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs
index a7bf1279f28..5e17fc98985 100644
--- a/src/librustc_session/options.rs
+++ b/src/librustc_session/options.rs
@@ -231,6 +231,7 @@ macro_rules! options {
 
     #[allow(non_upper_case_globals, dead_code)]
     mod $mod_desc {
+        pub const parse_no_flag: &str = "no value";
         pub const parse_bool: &str = "one of: `y`, `yes`, `on`, `n`, `no`, or `off`";
         pub const parse_opt_bool: &str = parse_bool;
         pub const parse_string: &str = "a string";
@@ -288,6 +289,15 @@ macro_rules! options {
             }
         )*
 
+        /// This is for boolean options that don't take a value and start with
+        /// `no-`. This style of option is deprecated.
+        fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool {
+            match v {
+                None => { *slot = true; true }
+                Some(_) => false,
+            }
+        }
+
         /// Use this for any boolean option that has a static default.
         fn parse_bool(slot: &mut bool, v: Option<&str>) -> bool {
             match v {
@@ -640,12 +650,12 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
         "set rpath values in libs/exes (default: no)"),
     overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
         "use overflow checks for integer arithmetic"),
-    no_prepopulate_passes: bool = (false, parse_bool, [TRACKED],
-        "give an empty list of passes to the pass manager (default: no)"),
-    no_vectorize_loops: bool = (false, parse_bool, [TRACKED],
-        "disable loop vectorization optimization passes (default: no)"),
-    no_vectorize_slp: bool = (false, parse_bool, [TRACKED],
-        "disable LLVM's SLP vectorization pass (default: no)"),
+    no_prepopulate_passes: bool = (false, parse_no_flag, [TRACKED],
+        "give an empty list of passes to the pass manager"),
+    no_vectorize_loops: bool = (false, parse_no_flag, [TRACKED],
+        "disable loop vectorization optimization passes"),
+    no_vectorize_slp: bool = (false, parse_no_flag, [TRACKED],
+        "disable LLVM's SLP vectorization pass"),
     soft_float: bool = (false, parse_bool, [TRACKED],
         "use soft float ABI (*eabihf targets only) (default: no)"),
     prefer_dynamic: bool = (false, parse_bool, [TRACKED],
@@ -664,7 +674,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
         "divide crate into N units to optimize in parallel"),
     remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED],
         "print remarks for these optimization passes (space separated, or \"all\")"),
-    no_stack_check: bool = (false, parse_bool, [UNTRACKED],
+    no_stack_check: bool = (false, parse_no_flag, [UNTRACKED],
         "this option is deprecated and does nothing"),
     debuginfo: usize = (0, parse_uint, [TRACKED],
         "debug info emission level (0 = no debug info, 1 = line tables only, \
@@ -725,8 +735,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "verify LLVM IR (default: no)"),
     borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
         "gather borrowck statistics (default: no)"),
-    no_landing_pads: bool = (false, parse_bool, [TRACKED],
-        "omit landing pads for unwinding (default: no)"),
+    no_landing_pads: bool = (false, parse_no_flag, [TRACKED],
+        "omit landing pads for unwinding"),
     fewer_names: bool = (false, parse_bool, [TRACKED],
         "reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) \
         (default: no)"),
@@ -758,8 +768,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "parse only; do not compile, assemble, or link (default: no)"),
     dual_proc_macros: bool = (false, parse_bool, [TRACKED],
         "load proc macros for both target and host, but only link to the target (default: no)"),
-    no_codegen: bool = (false, parse_bool, [TRACKED],
-        "run all passes except codegen; no output (default: no)"),
+    no_codegen: bool = (false, parse_no_flag, [TRACKED],
+        "run all passes except codegen; no output"),
     treat_err_as_bug: Option<usize> = (None, parse_treat_err_as_bug, [TRACKED],
         "treat error number `val` that occurs as bug"),
     report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
@@ -789,8 +799,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         (default: no)"),
     query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
         "enable queries of the dependency graph for regression testing (default: no)"),
-    no_analysis: bool = (false, parse_bool, [UNTRACKED],
-        "parse and expand the source, but run no analysis (default: no)"),
+    no_analysis: bool = (false, parse_no_flag, [UNTRACKED],
+        "parse and expand the source, but run no analysis"),
     unstable_options: bool = (false, parse_bool, [UNTRACKED],
         "adds unstable command line options to rustc interface (default: no)"),
     force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],
@@ -799,8 +809,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "for every macro invocation, print its name and arguments (default: no)"),
     debug_macros: bool = (false, parse_bool, [TRACKED],
         "emit line numbers debug info inside macros (default: no)"),
-    no_generate_arange_section: bool = (false, parse_bool, [TRACKED],
-        "omit DWARF address ranges that give faster lookups (default: no)"),
+    no_generate_arange_section: bool = (false, parse_no_flag, [TRACKED],
+        "omit DWARF address ranges that give faster lookups"),
     keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
         "keep hygiene data after analysis (default: no)"),
     show_span: Option<String> = (None, parse_opt_string, [TRACKED],
@@ -862,7 +872,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "extra arguments to prepend to the linker invocation (space separated)"),
     profile: bool = (false, parse_bool, [TRACKED],
         "insert profiling code (default: no)"),
-    no_profiler_runtime: bool = (false, parse_bool, [TRACKED],
+    no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
         "prevent automatic injection of the profiler_builtins crate"),
     relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
         "choose which RELRO level to use"),
@@ -911,12 +921,12 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         (default: no)"),
     share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
         "make the current crate share its generic instantiations"),
-    no_parallel_llvm: bool = (false, parse_bool, [UNTRACKED],
-        "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO) (default: no)"),
-    no_leak_check: bool = (false, parse_bool, [UNTRACKED],
-        "disable the 'leak check' for subtyping; unsound, but useful for tests (default: no)"),
-    no_interleave_lints: bool = (false, parse_bool, [UNTRACKED],
-        "execute lints separately; allows benchmarking individual lints (default: no)"),
+    no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
+        "run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
+    no_leak_check: bool = (false, parse_no_flag, [UNTRACKED],
+        "disable the 'leak check' for subtyping; unsound, but useful for tests"),
+    no_interleave_lints: bool = (false, parse_no_flag, [UNTRACKED],
+        "execute lints separately; allows benchmarking individual lints"),
     crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
         "inject the given attribute in the crate"),
     self_profile: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
@@ -953,8 +963,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
         "deduplicate identical diagnostics (default: yes)"),
     control_flow_guard: CFGuard = (CFGuard::Disabled, parse_cfguard, [UNTRACKED],
         "use Windows Control Flow Guard (`disabled`, `nochecks` or `checks`)"),
-    no_link: bool = (false, parse_bool, [TRACKED],
-        "compile without linking (default: no)"),
+    no_link: bool = (false, parse_no_flag, [TRACKED],
+        "compile without linking"),
     link_only: bool = (false, parse_bool, [TRACKED],
         "link the `.rlink` file generated by `-Z no-link` (default: no)"),
     new_llvm_pass_manager: bool = (false, parse_bool, [TRACKED],