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