@@ -921,12 +921,14 @@ impl<'a> StringReader<'a> {
921921 if string == "_" {
922922 token:: Underscore
923923 } else {
924- let is_mod_name = self . curr_is ( ':' ) && self . nextch_is ( ':' ) ;
925-
926924 // FIXME: perform NFKC normalization here. (Issue #2253)
927- token:: Ident ( str_to_ident ( string) , is_mod_name)
925+ if self . curr_is ( ':' ) && self . nextch_is ( ':' ) {
926+ token:: Ident ( str_to_ident ( string) , token:: ModName )
927+ } else {
928+ token:: Ident ( str_to_ident ( string) , token:: Plain )
929+ }
928930 }
929- } )
931+ } ) ;
930932 }
931933
932934 if is_dec_digit ( c) {
@@ -937,8 +939,11 @@ impl<'a> StringReader<'a> {
937939 match ( c. unwrap ( ) , self . nextch ( ) , self . nextnextch ( ) ) {
938940 ( '\x00' , Some ( 'n' ) , Some ( 'a' ) ) => {
939941 let ast_ident = self . scan_embedded_hygienic_ident ( ) ;
940- let is_mod_name = self . curr_is ( ':' ) && self . nextch_is ( ':' ) ;
941- return token:: Ident ( ast_ident, is_mod_name) ;
942+ return if self . curr_is ( ':' ) && self . nextch_is ( ':' ) {
943+ token:: Ident ( ast_ident, token:: ModName )
944+ } else {
945+ token:: Ident ( ast_ident, token:: Plain )
946+ } ;
942947 }
943948 _ => { }
944949 }
@@ -1056,7 +1061,7 @@ impl<'a> StringReader<'a> {
10561061 str_to_ident ( lifetime_name)
10571062 } ) ;
10581063 let keyword_checking_token =
1059- & token:: Ident ( keyword_checking_ident, false ) ;
1064+ & token:: Ident ( keyword_checking_ident, token :: Plain ) ;
10601065 let last_bpos = self . last_pos ;
10611066 if keyword_checking_token. is_keyword ( token:: keywords:: Self ) {
10621067 self . err_span_ ( start,
@@ -1434,7 +1439,7 @@ mod test {
14341439 assert_eq ! ( string_reader. next_token( ) . tok, token:: Whitespace ) ;
14351440 let tok1 = string_reader. next_token ( ) ;
14361441 let tok2 = TokenAndSpan {
1437- tok : token:: Ident ( id, false ) ,
1442+ tok : token:: Ident ( id, token :: Plain ) ,
14381443 sp : Span { lo : BytePos ( 21 ) , hi : BytePos ( 23 ) , expn_id : NO_EXPANSION } } ;
14391444 assert_eq ! ( tok1, tok2) ;
14401445 assert_eq ! ( string_reader. next_token( ) . tok, token:: Whitespace ) ;
@@ -1443,7 +1448,7 @@ mod test {
14431448 // read another token:
14441449 let tok3 = string_reader. next_token ( ) ;
14451450 let tok4 = TokenAndSpan {
1446- tok : token:: Ident ( str_to_ident ( "main" ) , false ) ,
1451+ tok : token:: Ident ( str_to_ident ( "main" ) , token :: Plain ) ,
14471452 sp : Span { lo : BytePos ( 24 ) , hi : BytePos ( 28 ) , expn_id : NO_EXPANSION } } ;
14481453 assert_eq ! ( tok3, tok4) ;
14491454 // the lparen is already read:
@@ -1458,39 +1463,45 @@ mod test {
14581463 }
14591464 }
14601465
1461- // make the identifier by looking up the string in the interner
1466+ # [ cfg ( stage0 ) ]
14621467 fn mk_ident ( id : & str , is_mod_name : bool ) -> token:: Token {
1463- token:: Ident ( str_to_ident ( id) , is_mod_name)
1468+ token:: Ident ( str_to_ident ( id) , is_mod_name)
1469+ }
1470+
1471+ // make the identifier by looking up the string in the interner
1472+ #[ cfg( not( stage0) ) ]
1473+ fn mk_ident ( id : & str , style : token:: IdentStyle ) -> token:: Token {
1474+ token:: Ident ( str_to_ident ( id) , style)
14641475 }
14651476
14661477 #[ test] fn doublecolonparsing ( ) {
14671478 check_tokenization ( setup ( & mk_sh ( ) , "a b" . to_string ( ) ) ,
1468- vec ! ( mk_ident( "a" , false ) ,
1469- token:: Whitespace ,
1470- mk_ident( "b" , false ) ) ) ;
1479+ vec ! [ mk_ident( "a" , token :: Plain ) ,
1480+ token:: Whitespace ,
1481+ mk_ident( "b" , token :: Plain ) ] ) ;
14711482 }
14721483
14731484 #[ test] fn dcparsing_2 ( ) {
14741485 check_tokenization ( setup ( & mk_sh ( ) , "a::b" . to_string ( ) ) ,
1475- vec ! ( mk_ident( "a" , true ) ,
1476- token:: ModSep ,
1477- mk_ident( "b" , false ) ) ) ;
1486+ vec ! [ mk_ident( "a" , token :: ModName ) ,
1487+ token:: ModSep ,
1488+ mk_ident( "b" , token :: Plain ) ] ) ;
14781489 }
14791490
14801491 #[ test] fn dcparsing_3 ( ) {
14811492 check_tokenization ( setup ( & mk_sh ( ) , "a ::b" . to_string ( ) ) ,
1482- vec ! ( mk_ident( "a" , false ) ,
1483- token:: Whitespace ,
1484- token:: ModSep ,
1485- mk_ident( "b" , false ) ) ) ;
1493+ vec ! [ mk_ident( "a" , token :: Plain ) ,
1494+ token:: Whitespace ,
1495+ token:: ModSep ,
1496+ mk_ident( "b" , token :: Plain ) ] ) ;
14861497 }
14871498
14881499 #[ test] fn dcparsing_4 ( ) {
14891500 check_tokenization ( setup ( & mk_sh ( ) , "a:: b" . to_string ( ) ) ,
1490- vec ! ( mk_ident( "a" , true ) ,
1491- token:: ModSep ,
1492- token:: Whitespace ,
1493- mk_ident( "b" , false ) ) ) ;
1501+ vec ! [ mk_ident( "a" , token :: ModName ) ,
1502+ token:: ModSep ,
1503+ token:: Whitespace ,
1504+ mk_ident( "b" , token :: Plain ) ] ) ;
14941505 }
14951506
14961507 #[ test] fn character_a ( ) {
0 commit comments