@@ -29,7 +29,7 @@ use rustc_middle::middle::cstore::MetadataLoader;
2929use rustc_save_analysis as save;
3030use rustc_save_analysis:: DumpHandler ;
3131use rustc_serialize:: json:: { self , ToJson } ;
32- use rustc_session:: config:: nightly_options;
32+ use rustc_session:: config:: { nightly_options, CG_OPTIONS , DB_OPTIONS } ;
3333use rustc_session:: config:: { ErrorOutputType , Input , OutputType , PrintRequest , TrimmedDefPaths } ;
3434use rustc_session:: getopts;
3535use rustc_session:: lint:: { Lint , LintId } ;
@@ -1010,9 +1010,18 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10101010 for option in config:: rustc_optgroups ( ) {
10111011 ( option. apply ) ( & mut options) ;
10121012 }
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+ } ) ;
10161025
10171026 // For all options we just parsed, we check a few aspects:
10181027 //
0 commit comments