@@ -220,8 +220,7 @@ impl<'a> StringReader<'a> {
220
220
if is_raw_ident {
221
221
ident_start = ident_start + BytePos ( 2 ) ;
222
222
}
223
- // FIXME: perform NFKC normalization here. (Issue #2253)
224
- let sym = self . symbol_from ( ident_start) ;
223
+ let sym = self . nfc_symbol_from ( ident_start) ;
225
224
if is_raw_ident {
226
225
let span = self . mk_sp ( start, self . pos ) ;
227
226
if !sym. can_be_raw ( ) {
@@ -466,6 +465,20 @@ impl<'a> StringReader<'a> {
466
465
Symbol :: intern ( self . str_from_to ( start, end) )
467
466
}
468
467
468
+ /// As symbol_from, with the text normalized into Unicode NFC form.
469
+ fn nfc_symbol_from ( & self , start : BytePos ) -> Symbol {
470
+ use unicode_normalization:: { is_nfc_quick, IsNormalized , UnicodeNormalization } ;
471
+ debug ! ( "taking an normalized ident from {:?} to {:?}" , start, self . pos) ;
472
+ let sym = self . str_from ( start) ;
473
+ match is_nfc_quick ( sym. chars ( ) ) {
474
+ IsNormalized :: Yes => Symbol :: intern ( sym) ,
475
+ _ => {
476
+ let sym_str: String = sym. chars ( ) . nfc ( ) . collect ( ) ;
477
+ Symbol :: intern ( & sym_str)
478
+ }
479
+ }
480
+ }
481
+
469
482
/// Slice of the source text spanning from `start` up to but excluding `end`.
470
483
fn str_from_to ( & self , start : BytePos , end : BytePos ) -> & str
471
484
{
0 commit comments