@@ -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 } ;
@@ -1017,9 +1017,18 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1017
1017
for option in config:: rustc_optgroups ( ) {
1018
1018
( option. apply ) ( & mut options) ;
1019
1019
}
1020
- let matches = options
1021
- . parse ( args)
1022
- . unwrap_or_else ( |f| early_error ( ErrorOutputType :: default ( ) , & f. to_string ( ) ) ) ;
1020
+ let matches = options. parse ( args) . unwrap_or_else ( |e| {
1021
+ let msg = match e {
1022
+ getopts:: Fail :: UnrecognizedOption ( ref opt) => CG_OPTIONS
1023
+ . iter ( )
1024
+ . map ( |& ( name, ..) | ( 'C' , name) )
1025
+ . chain ( DB_OPTIONS . iter ( ) . map ( |& ( name, ..) | ( 'Z' , name) ) )
1026
+ . find ( |& ( _, name) | * opt == name. replace ( "_" , "-" ) )
1027
+ . map ( |( flag, _) | format ! ( "{}. Did you mean `-{} {}`?" , e, flag, opt) ) ,
1028
+ _ => None ,
1029
+ } ;
1030
+ early_error ( ErrorOutputType :: default ( ) , & msg. unwrap_or_else ( || e. to_string ( ) ) ) ;
1031
+ } ) ;
1023
1032
1024
1033
// For all options we just parsed, we check a few aspects:
1025
1034
//
0 commit comments