-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify the internal API for declaring command-line options #132754
Conversation
rustbot has assigned @GuillaumeGomez. Use |
The run-make-support library was changed cc @jieyouxu This PR modifies cc @jieyouxu |
"Link the generated crate(s) to the specified native\n\ | ||
library NAME. The optional KIND can be one of\n\ | ||
static, framework, or dylib (the default).\n\ | ||
Optional comma separated MODIFIERS\n\ | ||
(bundle|verbatim|whole-archive|as-needed)\n\ | ||
may be specified each with a prefix of either '+' to\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC this is one of the entries that used to confuse rustfmt, causing the rest of the list to quietly not be auto-formatted at all.
Replacing the hard line-breaks with \n\
seems to work around that, without changing the output seen by the new run-make test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, thanks! I'll let someone from the compiler team confirm it's good on their side as well.
Hmm, it occurs to me that the help output is slightly different on beta/stable, but only if Looking at some of the other run-make tests, it seems that they already pass |
rust/src/bootstrap/src/core/build_steps/test.rs Line 2091 in 4b198d6
so it shouldn't cause problems beta bumping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks like a significant readibility cleanup for the options handling! One minor question, but otherwise looks good.
opt( | ||
Stable, | ||
Multi, | ||
"", | ||
"cfg", | ||
"Configure the compilation environment.\n\ | ||
SPEC supports the syntax `NAME[=\"VALUE\"]`.", | ||
"SPEC", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: what does rustc_short_optgroups
actually mean?
Returns the "short" subset of the rustc command line options
Like the options that have a shorthand...? I was trying to figure out what the distinction of rustc_short_optgroups
vs rustc_optgroups
was lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, this doesn't have to be in this PR (probably for the better).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it means “the subset of options that we print when running rustc --help
without -v
”.
It’s not a great name!
@bors r=GuillaumeGomez,jieyouxu |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#132341 (Reject raw lifetime followed by `'`, like regular lifetimes do) - rust-lang#132363 (Enforce that raw lifetimes must be valid raw identifiers) - rust-lang#132744 (add regression test for rust-lang#90781) - rust-lang#132754 (Simplify the internal API for declaring command-line options) - rust-lang#132772 (use `download-rustc="if-unchanged"` as a global default) - rust-lang#132774 (Use lld with non-LLVM backends) - rust-lang#132799 (Make `Ty::primitive_symbol` recognize `str`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132754 - Zalathar:opts, r=GuillaumeGomez,jieyouxu Simplify the internal API for declaring command-line options The internal APIs for declaring command-line options are old, and intimidatingly complex. This PR replaces them with a single function that takes explicit `stability` and `kind` arguments, making it easier to see how each option is handled, and whether it is treated as stable or unstable. We also don't appear to have any tests for the output of `rustc --help` and similar, so I've added a run-make test to verify that this PR doesn't change any output. (There is already a similar run-make test for rustdoc's help output.) --- The librustdoc changes are simply adjusting to updated compiler APIs; no functional change intended. --- A side-effect of these changes is that rustfmt can once again format the entirety of these option declaration lists, which it was not doing before.
Remove `rustc_session::config::rustc_short_optgroups` Follow-up to rust-lang#132754 (comment). 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.
Rollup merge of rust-lang#132891 - Zalathar:short-opt-groups, r=jieyouxu Remove `rustc_session::config::rustc_short_optgroups` Follow-up to rust-lang#132754 (comment). 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.
…eyouxu Simplify the internal API for declaring command-line options The internal APIs for declaring command-line options are old, and intimidatingly complex. This PR replaces them with a single function that takes explicit `stability` and `kind` arguments, making it easier to see how each option is handled, and whether it is treated as stable or unstable. We also don't appear to have any tests for the output of `rustc --help` and similar, so I've added a run-make test to verify that this PR doesn't change any output. (There is already a similar run-make test for rustdoc's help output.) --- The librustdoc changes are simply adjusting to updated compiler APIs; no functional change intended. --- A side-effect of these changes is that rustfmt can once again format the entirety of these option declaration lists, which it was not doing before.
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#132341 (Reject raw lifetime followed by `'`, like regular lifetimes do) - rust-lang#132363 (Enforce that raw lifetimes must be valid raw identifiers) - rust-lang#132744 (add regression test for rust-lang#90781) - rust-lang#132754 (Simplify the internal API for declaring command-line options) - rust-lang#132772 (use `download-rustc="if-unchanged"` as a global default) - rust-lang#132774 (Use lld with non-LLVM backends) - rust-lang#132799 (Make `Ty::primitive_symbol` recognize `str`) r? `@ghost` `@rustbot` modify labels: rollup
Remove `rustc_session::config::rustc_short_optgroups` Follow-up to rust-lang#132754 (comment). 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.
The internal APIs for declaring command-line options are old, and intimidatingly complex. This PR replaces them with a single function that takes explicit
stability
andkind
arguments, making it easier to see how each option is handled, and whether it is treated as stable or unstable.We also don't appear to have any tests for the output of
rustc --help
and similar, so I've added a run-make test to verify that this PR doesn't change any output. (There is already a similar run-make test for rustdoc's help output.)The librustdoc changes are simply adjusting to updated compiler APIs; no functional change intended.
A side-effect of these changes is that rustfmt can once again format the entirety of these option declaration lists, which it was not doing before.