@@ -10,7 +10,7 @@ use rustc_codegen_ssa::traits::CodegenBackend;
1010use rustc_data_structures:: parallel;
1111use rustc_data_structures:: sync:: { Lrc , OnceCell , WorkerLocal } ;
1212use rustc_data_structures:: temp_dir:: MaybeTempDir ;
13- use rustc_errors:: { ErrorReported , PResult } ;
13+ use rustc_errors:: { Applicability , ErrorReported , PResult } ;
1414use rustc_expand:: base:: ExtCtxt ;
1515use rustc_hir:: def_id:: { StableCrateId , LOCAL_CRATE } ;
1616use rustc_hir:: Crate ;
@@ -456,10 +456,26 @@ pub fn configure_and_expand(
456456 identifiers. sort_by_key ( |& ( key, _) | key) ;
457457 for ( ident, mut spans) in identifiers. into_iter ( ) {
458458 spans. sort ( ) ;
459- sess. diagnostic ( ) . span_err (
460- MultiSpan :: from ( spans) ,
461- & format ! ( "identifiers cannot contain emoji: `{}`" , ident) ,
462- ) ;
459+ if ident == sym:: ferris {
460+ let first_span = spans[ 0 ] ;
461+ sess. diagnostic ( )
462+ . struct_span_err (
463+ MultiSpan :: from ( spans) ,
464+ "Ferris cannot be used as an identifier" ,
465+ )
466+ . span_suggestion (
467+ first_span,
468+ "try using their name instead" ,
469+ "ferris" . to_string ( ) ,
470+ Applicability :: MaybeIncorrect ,
471+ )
472+ . emit ( ) ;
473+ } else {
474+ sess. diagnostic ( ) . span_err (
475+ MultiSpan :: from ( spans) ,
476+ & format ! ( "identifiers cannot contain emoji: `{}`" , ident) ,
477+ ) ;
478+ }
463479 }
464480 } ) ;
465481
0 commit comments