about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src/lib.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-11-11 15:23:34 +0100
committerGitHub <noreply@github.com>2024-11-11 15:23:34 +0100
commitbcd85e5434a4eac6ce75cc5daf0334c7d7f38229 (patch)
treeb567b28bebc9367b81b5314a73a0e4c9e9dd3c8d /compiler/rustc_driver_impl/src/lib.rs
parent731966692372d33d7abf56b68ec317da0ccb63bd (diff)
parent8b4701d74cc7bc1a9532716fd2bd25579102115d (diff)
downloadrust-bcd85e5434a4eac6ce75cc5daf0334c7d7f38229.tar.gz
rust-bcd85e5434a4eac6ce75cc5daf0334c7d7f38229.zip
Rollup merge of #132891 - Zalathar:short-opt-groups, r=jieyouxu
Remove `rustc_session::config::rustc_short_optgroups`

Follow-up to https://github.com/rust-lang/rust/pull/132754#discussion_r1835427349.

The name `rustc_short_optgroups` has always been confusing, because it is unrelated to the distinction between short and long options (i.e. `-s` vs `--long`), and instead means something like “the subset of command-line options that are printed by `rustc --help` without `-v`”.

So let's merge that function into the main `rustc_optgroups`, and store the relevant bit of information in a boolean field in `RustcOptGroup` instead.

---

This PR also modifies `RustcOptGroup` to store its various strings directly, instead of inside a boxed `apply` closure. That turned out to not be necessary for the main change, but is a worthwhile cleanup in its own right.
Diffstat (limited to 'compiler/rustc_driver_impl/src/lib.rs')
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index 78ba841d89f..b6f7abed6f3 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -934,9 +934,12 @@ pub fn version_at_macro_invocation(
 }
 
 fn usage(verbose: bool, include_unstable_options: bool, nightly_build: bool) {
-    let groups = if verbose { config::rustc_optgroups() } else { config::rustc_short_optgroups() };
     let mut options = getopts::Options::new();
-    for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
+    for option in config::rustc_optgroups()
+        .iter()
+        .filter(|x| verbose || !x.is_verbose_help_only)
+        .filter(|x| include_unstable_options || x.is_stable())
+    {
         option.apply(&mut options);
     }
     let message = "Usage: rustc [OPTIONS] INPUT";