Skip to content

Commit 93f69b2

Browse files
committed
Don't skip argument parsing when running rustc with no arguments
Setting up the argument parser to parse no arguments is a tiny bit of wasted work, but avoids an otherwise-unnecessary special case. In particular, this lets us avoid having to deal with multiple different APIs to determine whether the compiler is nightly or not.
1 parent 1d55f72 commit 93f69b2

File tree

1 file changed

+1
-10
lines changed
  • compiler/rustc_driver_impl/src

1 file changed

+1
-10
lines changed

compiler/rustc_driver_impl/src/lib.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -1191,15 +1191,6 @@ fn print_flag_list<T>(cmdline_opt: &str, flag_list: &[OptionDesc<T>]) {
11911191
/// be public when using rustc as a library, see
11921192
/// <https://github.com/rust-lang/rust/commit/2b4c33817a5aaecabf4c6598d41e190080ec119e>
11931193
pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<getopts::Matches> {
1194-
if args.is_empty() {
1195-
// user did not write `-v` nor `-Z unstable-options`, so do not
1196-
// include that extra information.
1197-
let nightly_build =
1198-
rustc_feature::UnstableFeatures::from_environment(None).is_nightly_build();
1199-
usage(false, false, nightly_build);
1200-
return None;
1201-
}
1202-
12031194
// Parse with *all* options defined in the compiler, we don't worry about
12041195
// option stability here we just want to parse as much as possible.
12051196
let mut options = getopts::Options::new();
@@ -1245,7 +1236,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
12451236
// (unstable option being used on stable)
12461237
nightly_options::check_nightly_options(early_dcx, &matches, &config::rustc_optgroups());
12471238

1248-
if matches.opt_present("h") || matches.opt_present("help") {
1239+
if args.is_empty() || matches.opt_present("h") || matches.opt_present("help") {
12491240
// Only show unstable options in --help if we accept unstable options.
12501241
let unstable_enabled = nightly_options::is_unstable_enabled(&matches);
12511242
let nightly_build = nightly_options::match_is_nightly_build(&matches);

0 commit comments

Comments
 (0)