@@ -6,6 +6,7 @@ use std::path::PathBuf;
66use std:: str:: FromStr ;
77
88use rustc_data_structures:: fx:: FxHashMap ;
9+ use rustc_driver:: print_flag_list;
910use rustc_session:: config:: {
1011 self , parse_crate_types_from_list, parse_externs, parse_target_triple, CrateType ,
1112} ;
@@ -310,11 +311,12 @@ impl RenderOptions {
310311impl Options {
311312 /// Parses the given command-line for options. If an error message or other early-return has
312313 /// been printed, returns `Err` with the exit code.
313- pub ( crate ) fn from_matches ( matches : & getopts:: Matches ) -> Result < Options , i32 > {
314+ pub ( crate ) fn from_matches ( matches : & getopts:: Matches , args : Vec < String > ) -> Result < Options , i32 > {
315+ let args = & args[ 1 ..] ;
314316 // Check for unstable options.
315317 nightly_options:: check_nightly_options ( matches, & opts ( ) ) ;
316318
317- if matches. opt_present ( "h" ) || matches. opt_present ( "help" ) {
319+ if args . is_empty ( ) || matches. opt_present ( "h" ) || matches. opt_present ( "help" ) {
318320 crate :: usage ( "rustdoc" ) ;
319321 return Err ( 0 ) ;
320322 } else if matches. opt_present ( "version" ) {
@@ -335,6 +337,21 @@ impl Options {
335337 // check for deprecated options
336338 check_deprecated_options ( matches, & diag) ;
337339
340+ let z_flags = matches. opt_strs ( "Z" ) ;
341+ if z_flags. iter ( ) . any ( |x| * x == "help" ) {
342+ print_flag_list ( "-Z" , config:: DB_OPTIONS ) ;
343+ return Err ( 0 ) ;
344+ }
345+ let c_flags = matches. opt_strs ( "C" ) ;
346+ if c_flags. iter ( ) . any ( |x| * x == "help" ) {
347+ print_flag_list ( "-C" , config:: CG_OPTIONS ) ;
348+ return Err ( 0 ) ;
349+ }
350+ let w_flags = matches. opt_strs ( "W" ) ;
351+ if w_flags. iter ( ) . any ( |x| * x == "help" ) {
352+ print_flag_list ( "-W" , config:: DB_OPTIONS ) ;
353+ return Err ( 0 ) ;
354+ }
338355 if matches. opt_strs ( "passes" ) == [ "list" ] {
339356 println ! ( "Available passes for running rustdoc:" ) ;
340357 for pass in passes:: PASSES {
@@ -415,6 +432,7 @@ impl Options {
415432 }
416433 return Err ( 0 ) ;
417434 }
435+ let ( _lint_opts, _describe_lints, _lint_cap) = get_cmd_lint_options ( matches, error_format) ;
418436
419437 if matches. free . is_empty ( ) {
420438 diag. struct_err ( "missing file operand" ) . emit ( ) ;
0 commit comments