@@ -219,8 +219,7 @@ impl<'a> StringReader<'a> {
219219 if is_raw_ident {
220220 ident_start = ident_start + BytePos ( 2 ) ;
221221 }
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) ;
224223 if is_raw_ident {
225224 let span = self . mk_sp ( start, self . pos ) ;
226225 if !sym. can_be_raw ( ) {
@@ -465,6 +464,20 @@ impl<'a> StringReader<'a> {
465464 Symbol :: intern ( self . str_from_to ( start, end) )
466465 }
467466
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+
468481 /// Slice of the source text spanning from `start` up to but excluding `end`.
469482 fn str_from_to ( & self , start : BytePos , end : BytePos ) -> & str
470483 {
0 commit comments