@@ -29,7 +29,7 @@ use rustc_middle::middle::cstore::MetadataLoader;
29
29
use rustc_save_analysis as save;
30
30
use rustc_save_analysis:: DumpHandler ;
31
31
use rustc_serialize:: json:: { self , ToJson } ;
32
- use rustc_session:: config:: nightly_options;
32
+ use rustc_session:: config:: { nightly_options, CG_OPTIONS , DB_OPTIONS } ;
33
33
use rustc_session:: config:: { ErrorOutputType , Input , OutputType , PrintRequest , TrimmedDefPaths } ;
34
34
use rustc_session:: getopts;
35
35
use rustc_session:: lint:: { Lint , LintId } ;
@@ -1010,9 +1010,18 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1010
1010
for option in config:: rustc_optgroups ( ) {
1011
1011
( option. apply ) ( & mut options) ;
1012
1012
}
1013
- let matches = options
1014
- . parse ( args)
1015
- . unwrap_or_else ( |f| early_error ( ErrorOutputType :: default ( ) , & f. to_string ( ) ) ) ;
1013
+ let matches = options. parse ( args) . unwrap_or_else ( |e| {
1014
+ let msg = match e {
1015
+ getopts:: Fail :: UnrecognizedOption ( ref opt) => CG_OPTIONS
1016
+ . iter ( )
1017
+ . map ( |& ( name, ..) | ( 'C' , name) )
1018
+ . chain ( DB_OPTIONS . iter ( ) . map ( |& ( name, ..) | ( 'Z' , name) ) )
1019
+ . find ( |& ( _, name) | * opt == name. replace ( "_" , "-" ) )
1020
+ . map ( |( flag, _) | format ! ( "{}. Did you mean `-{} {}`?" , e, flag, opt) ) ,
1021
+ _ => None ,
1022
+ } ;
1023
+ early_error ( ErrorOutputType :: default ( ) , & msg. unwrap_or_else ( || e. to_string ( ) ) ) ;
1024
+ } ) ;
1016
1025
1017
1026
// For all options we just parsed, we check a few aspects:
1018
1027
//
0 commit comments