@@ -572,6 +572,35 @@ impl<'a> AstValidator<'a> {
572572 . emit ( ) ;
573573 }
574574
575+ fn check_nomangle_item_asciionly ( & self , ident : Ident , item_span : Span ) {
576+ if ident. name . as_str ( ) . is_ascii ( ) {
577+ return ;
578+ }
579+ let head_span = self . session . source_map ( ) . guess_head_span ( item_span) ;
580+ struct_span_err ! (
581+ self . session,
582+ head_span,
583+ E0754 ,
584+ "`#[no_mangle]` requires ASCII identifier"
585+ )
586+ . emit ( ) ;
587+ }
588+
589+ fn check_mod_file_item_asciionly ( & self , ident : Ident ) {
590+ if ident. name . as_str ( ) . is_ascii ( ) {
591+ return ;
592+ }
593+ struct_span_err ! (
594+ self . session,
595+ ident. span,
596+ E0754 ,
597+ "trying to load file for module `{}` with non ascii identifer name" ,
598+ ident. name
599+ )
600+ . help ( "consider using `#[path]` attribute to specify filesystem path" )
601+ . emit ( ) ;
602+ }
603+
575604 fn deny_generic_params ( & self , generics : & Generics , ident_span : Span ) {
576605 if !generics. params . is_empty ( ) {
577606 struct_span_err ! (
@@ -866,6 +895,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
866895 self . has_proc_macro_decls = true ;
867896 }
868897
898+ if attr:: contains_name ( & item. attrs , sym:: no_mangle) {
899+ self . check_nomangle_item_asciionly ( item. ident , item. span ) ;
900+ }
901+
869902 match item. kind {
870903 ItemKind :: Impl {
871904 unsafety,
@@ -992,9 +1025,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
9921025 walk_list ! ( self , visit_attribute, & item. attrs) ;
9931026 return ;
9941027 }
995- ItemKind :: Mod ( _ ) => {
1028+ ItemKind :: Mod ( Mod { inline , .. } ) => {
9961029 // Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
997- attr:: first_attr_value_str_by_name ( & item. attrs , sym:: path) ;
1030+ if !inline && !attr:: contains_name ( & item. attrs , sym:: path) {
1031+ self . check_mod_file_item_asciionly ( item. ident ) ;
1032+ }
9981033 }
9991034 ItemKind :: Union ( ref vdata, _) => {
10001035 if let VariantData :: Tuple ( ..) | VariantData :: Unit ( ..) = vdata {
0 commit comments