@@ -65,27 +65,32 @@ impl EarlyLintPass for DisallowedScriptIdents {
65
65
// https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint/src/non_ascii_idents.rs
66
66
67
67
let check_disallowed_script_idents = cx. builder . lint_level ( DISALLOWED_SCRIPT_IDENTS ) . 0 != Level :: Allow ;
68
-
69
68
if !check_disallowed_script_idents {
70
69
return ;
71
70
}
72
71
73
72
let symbols = cx. sess . parse_sess . symbol_gallery . symbols . lock ( ) ;
74
-
75
73
// Sort by `Span` so that error messages make sense with respect to the
76
74
// order of identifier locations in the code.
77
75
let mut symbols: Vec < _ > = symbols. iter ( ) . collect ( ) ;
78
76
symbols. sort_unstable_by_key ( |k| k. 1 ) ;
79
77
80
78
for ( symbol, & span) in & symbols {
79
+ // Note: `symbol.as_str()` is an expensive operation, thus should not be called
80
+ // more than once for a single symbol.
81
81
let symbol_str = symbol. as_str ( ) ;
82
82
if symbol_str. is_ascii ( ) {
83
83
continue ;
84
84
}
85
85
86
86
for c in symbol_str. chars ( ) {
87
- let script = c. script ( ) ;
88
- if !self . whitelist . contains ( & script) {
87
+ // We want to iterate through all the scripts associated with this character
88
+ // and check whether at least of one scripts is in the whitelist.
89
+ let forbidden_script = c
90
+ . script_extension ( )
91
+ . iter ( )
92
+ . find ( |script| !self . whitelist . contains ( script) ) ;
93
+ if let Some ( script) = forbidden_script {
89
94
span_lint (
90
95
cx,
91
96
DISALLOWED_SCRIPT_IDENTS ,
0 commit comments