pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
    // Throw away the first argument, the name of the binary
    let args = &args[1..];

    if args.is_empty() {
        // user did not write `-v` nor `-Z unstable-options`, so do not
        // include that extra information.
        usage(false, false);
        return None;
    }

    // Parse with *all* options defined in the compiler, we don't worry about
    // option stability here we just want to parse as much as possible.
    let mut options = getopts::Options::new();
    for option in config::rustc_optgroups() {
        (option.apply)(&mut options);
    }
    let matches = match options.parse(args) {
        Ok(m) => m,
        Err(f) => early_error(ErrorOutputType::default(), &f.to_string()),
    };

    // For all options we just parsed, we check a few aspects:
    //
    // * If the option is stable, we're all good
    // * If the option wasn't passed, we're all good
    // * If `-Z unstable-options` wasn't passed (and we're not a -Z option
    //   ourselves), then we require the `-Z unstable-options` flag to unlock
    //   this option that was passed.
    // * If we're a nightly compiler, then unstable options are now unlocked, so
    //   we're good to go.
    // * Otherwise, if we're a truly unstable option then we generate an error
    //   (unstable option being used on stable)
    // * If we're a historically stable-but-should-be-unstable option then we
    //   emit a warning that we're going to turn this into an error soon.
    nightly_options::check_nightly_options(&matches, &config::rustc_optgroups());

    if matches.opt_present("h") || matches.opt_present("help") {
        // Only show unstable options in --help if we *really* accept unstable
        // options, which catches the case where we got `-Z unstable-options` on
        // the stable channel of Rust which was accidentally allowed
        // historically.
        usage(matches.opt_present("verbose"),
              nightly_options::is_unstable_enabled(&matches));
        return None;
    }

    // Handle the special case of -Wall.
    let wall = matches.opt_strs("W");
    if wall.iter().any(|x| *x == "all") {
        print_wall_help();
        return None;
    }

    // Don't handle -W help here, because we might first load plugins.
    let r = matches.opt_strs("Z");
    if r.iter().any(|x| *x == "help") {
        describe_debug_flags();
        return None;
    }

    let cg_flags = matches.opt_strs("C");
    if cg_flags.iter().any(|x| *x == "help") {
        describe_codegen_flags();
        return None;
    }

    if cg_flags.iter().any(|x| *x == "no-stack-check") {
        early_warn(ErrorOutputType::default(),
                   "the --no-stack-check flag is deprecated and does nothing");
    }

    if cg_flags.contains(&"passes=list".to_string()) {
        get_codegen_sysroot("llvm")().print_passes();
        return None;
    }

    if matches.opt_present("version") {
        version("rustc", &matches);
        return None;
    }

    Some(matches)
}
/// Process command line options. Emits messages as appropriate. If compilation
/// should continue, returns a getopts::Matches object parsed from args,
/// otherwise returns None.
///
/// The compiler's handling of options is a little complicated as it ties into
/// our stability story, and it's even *more* complicated by historical
/// accidents. The current intention of each compiler option is to have one of
/// three modes:
///
/// 1. An option is stable and can be used everywhere.
/// 2. An option is unstable, but was historically allowed on the stable
///    channel.
/// 3. An option is unstable, and can only be used on nightly.
///
/// Like unstable library and language features, however, unstable options have
/// always required a form of "opt in" to indicate that you're using them. This
/// provides the easy ability to scan a code base to check to see if anything
/// unstable is being used. Currently, this "opt in" is the `-Z` "zed" flag.
///
/// All options behind `-Z` are considered unstable by default. Other top-level
/// options can also be considered unstable, and they were unlocked through the
/// `-Z unstable-options` flag. Note that `-Z` remains to be the root of
/// instability in both cases, though.
///
/// So with all that in mind, the comments below have some more detail about the
/// contortions done here to get things to work out correctly.
Process command line options. Emits messages as appropriate. If compilation
should continue, returns a getopts::Matches object parsed from args,
otherwise returns None.

The compiler's handling of options is a little complicated as it ties into
our stability story, and it's even *more* complicated by historical
accidents. The current intention of each compiler option is to have one of
three modes.

1. An option is stable and can be used everywhere.
2. An option is unstable, but was historically allowed on the stable
channel.
3. An option is unstable, and can only be used on nightly.

Like unstable library and language features, however, unstable options have
always required a form of "opt in" to indicate that you're using them. This
provides the easy ability to scan a code base to check to see if anything
unstable is being used. Currently, this "opt in" is the `-Z` "zed" flag.

All options behind `-Z` are considered unstable by default. Other top-level
options can also be considered unstable, and they were unlocked through the
`-Z unstable-options` flag. Note that `-Z` remains to be the root of
instability in both cases, though.

So with all that in mind, the comments below have some more detail about the
contortions done here to get things to work out correctly.
Process command line options . Emits messages as appropriate . If compilation should continue returns a getopts :: Matches object parsed from args otherwise returns None . The compiler ' s handling of options is a little complicated as it ties into our stability story and it ' s even * more * complicated by historical accidents . The current intention of each compiler option is to have one of three modes . 1 . An option is stable and can be used everywhere . 2 . An option is unstable but was historically allowed on the stable channel . 3 . An option is unstable and can only be used on nightly . Like unstable library and language features however unstable options have always required a form of " opt in " to indicate that you ' re using them . This provides the easy ability to scan a code base to check to see if anything unstable is being used . Currently this " opt in " is the ` - Z ` " zed " flag . All options behind ` - Z ` are considered unstable by default . Other top - level options can also be considered unstable and they were unlocked through the ` - Z unstable - options ` flag . Note that ` - Z ` remains to be the root of instability in both cases though . So with all that in mind the comments below have some more detail about the contortions done here to get things to work out correctly .
pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
    // Throw away the first argument, the name of the binary
    let args = &args[1..];
    if args.is_empty() {
        // user did not write `-v` nor `-Z unstable-options`, so do not
        // include that extra information.
        usage(false, false);
        return None;
    }
    // Parse with *all* options defined in the compiler, we don't worry about
    // option stability here we just want to parse as much as possible.
    let mut options = getopts::Options::new();
    for option in config::rustc_optgroups() {
        (option.apply)(&mut options);
    }
    let matches = match options.parse(args) {
        Ok(m) => m,
        Err(f) => early_error(ErrorOutputType::default(), &f.to_string()),
    };
    // For all options we just parsed, we check a few aspects:
    //
    // * If the option is stable, we're all good
    // * If the option wasn't passed, we're all good
    // * If `-Z unstable-options` wasn't passed (and we're not a -Z option
    //   ourselves), then we require the `-Z unstable-options` flag to unlock
    //   this option that was passed.
    // * If we're a nightly compiler, then unstable options are now unlocked, so
    //   we're good to go.
    // * Otherwise, if we're a truly unstable option then we generate an error
    //   (unstable option being used on stable)
    // * If we're a historically stable-but-should-be-unstable option then we
    //   emit a warning that we're going to turn this into an error soon.
    nightly_options::check_nightly_options(&matches, &config::rustc_optgroups());
    if matches.opt_present("h") || matches.opt_present("help") {
        // Only show unstable options in --help if we *really* accept unstable
        // options, which catches the case where we got `-Z unstable-options` on
        // the stable channel of Rust which was accidentally allowed
        // historically.
        usage(matches.opt_present("verbose"),
              nightly_options::is_unstable_enabled(&matches));
        return None;
    }
    // Handle the special case of -Wall.
    let wall = matches.opt_strs("W");
    if wall.iter().any(|x| *x == "all") {
        print_wall_help();
        return None;
    }
    // Don't handle -W help here, because we might first load plugins.
    let r = matches.opt_strs("Z");
    if r.iter().any(|x| *x == "help") {
        describe_debug_flags();
        return None;
    }
    let cg_flags = matches.opt_strs("C");
    if cg_flags.iter().any(|x| *x == "help") {
        describe_codegen_flags();
        return None;
    }
    if cg_flags.iter().any(|x| *x == "no-stack-check") {
        early_warn(ErrorOutputType::default(),
                   "the --no-stack-check flag is deprecated and does nothing");
    }
    if cg_flags.contains(&"passes=list".to_string()) {
        get_codegen_sysroot("llvm")().print_passes();
        return None;
    }
    if matches.opt_present("version") {
        version("rustc", &matches);
        return None;
    }
    Some(matches)
}
pub fn handle_options ( args : & [ String ] ) -> Option < getopts :: Matches > { // Throw away the first argument, the name of the binary let args = & args [ 1 .. ] ; if args . is_empty ( ) { // user did not write `-v` nor `-Z unstable-options`, so do not // include that extra information. usage ( false , false ) ; return None ; } // Parse with *all* options defined in the compiler, we don't worry about // option stability here we just want to parse as much as possible. let mut options = getopts :: Options :: new ( ) ; for option in config :: rustc_optgroups ( ) { ( option . apply ) ( & mut options ) ; } let matches = match options . parse ( args ) { Ok ( m ) => m , Err ( f ) => early_error ( ErrorOutputType :: default ( ) , & f . to_string ( ) ) , } ; // For all options we just parsed, we check a few aspects: // // * If the option is stable, we're all good // * If the option wasn't passed, we're all good // * If `-Z unstable-options` wasn't passed (and we're not a -Z option //   ourselves), then we require the `-Z unstable-options` flag to unlock //   this option that was passed. // * If we're a nightly compiler, then unstable options are now unlocked, so //   we're good to go. // * Otherwise, if we're a truly unstable option then we generate an error //   (unstable option being used on stable) // * If we're a historically stable-but-should-be-unstable option then we //   emit a warning that we're going to turn this into an error soon. nightly_options :: check_nightly_options ( & matches , & config :: rustc_optgroups ( ) ) ; if matches . opt_present ( " " ) || matches . opt_present ( " " ) { // Only show unstable options in --help if we *really* accept unstable // options, which catches the case where we got `-Z unstable-options` on // the stable channel of Rust which was accidentally allowed // historically. usage ( matches . opt_present ( " " ) , nightly_options :: is_unstable_enabled ( & matches ) ) ; return None ; } // Handle the special case of -Wall. let wall = matches . opt_strs ( " " ) ; if wall . iter ( ) . any ( | x | * x == " " ) { print_wall_help ( ) ; return None ; } // Don't handle -W help here, because we might first load plugins. let r = matches . opt_strs ( " " ) ; if r . iter ( ) . any ( | x | * x == " " ) { describe_debug_flags ( ) ; return None ; } let cg_flags = matches . opt_strs ( " " ) ; if cg_flags . iter ( ) . any ( | x | * x == " " ) { describe_codegen_flags ( ) ; return None ; } if cg_flags . iter ( ) . any ( | x | * x == " " ) { early_warn ( ErrorOutputType :: default ( ) , " " ) ; } if cg_flags . contains ( & " " . to_string ( ) ) { get_codegen_sysroot ( " " ) ( ) . print_passes ( ) ; return None ; } if matches . opt_present ( " " ) { version ( " " , & matches ) ; return None ; } Some ( matches ) }
Process command line options.
Process command line options .
args
&[String]
args
&[String]