@@ -572,6 +572,35 @@ impl<'a> AstValidator<'a> {
572
572
. emit ( ) ;
573
573
}
574
574
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
+
575
604
fn deny_generic_params ( & self , generics : & Generics , ident_span : Span ) {
576
605
if !generics. params . is_empty ( ) {
577
606
struct_span_err ! (
@@ -866,6 +895,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
866
895
self . has_proc_macro_decls = true ;
867
896
}
868
897
898
+ if attr:: contains_name ( & item. attrs , sym:: no_mangle) {
899
+ self . check_nomangle_item_asciionly ( item. ident , item. span ) ;
900
+ }
901
+
869
902
match item. kind {
870
903
ItemKind :: Impl {
871
904
unsafety,
@@ -992,9 +1025,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
992
1025
walk_list ! ( self , visit_attribute, & item. attrs) ;
993
1026
return ;
994
1027
}
995
- ItemKind :: Mod ( _ ) => {
1028
+ ItemKind :: Mod ( Mod { inline , .. } ) => {
996
1029
// 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
+ }
998
1033
}
999
1034
ItemKind :: Union ( ref vdata, _) => {
1000
1035
if let VariantData :: Tuple ( ..) | VariantData :: Unit ( ..) = vdata {
0 commit comments