@@ -920,43 +920,43 @@ impl Token {
920920
921921 /// Returns `true` if the token is a given keyword, `kw`.
922922 pub fn is_keyword ( & self , kw : Symbol ) -> bool {
923- self . is_non_raw_ident_where ( |id| id. name == kw)
923+ self . non_raw_ident ( ) . is_some_and ( |id| id. name == kw)
924924 }
925925
926926 /// Returns `true` if the token is a given keyword, `kw` or if `case` is `Insensitive` and this
927927 /// token is an identifier equal to `kw` ignoring the case.
928928 pub fn is_keyword_case ( & self , kw : Symbol , case : Case ) -> bool {
929929 self . is_keyword ( kw)
930930 || ( case == Case :: Insensitive
931- && self . is_non_raw_ident_where ( |id| {
931+ && self . non_raw_ident ( ) . is_some_and ( |id| {
932932 // Do an ASCII case-insensitive match, because all keywords are ASCII.
933933 id. name . as_str ( ) . eq_ignore_ascii_case ( kw. as_str ( ) )
934934 } ) )
935935 }
936936
937937 pub fn is_path_segment_keyword ( & self ) -> bool {
938- self . is_non_raw_ident_where ( sp:: Ident :: is_path_segment_keyword)
938+ self . non_raw_ident ( ) . is_some_and ( sp:: Ident :: is_path_segment_keyword)
939939 }
940940
941941 /// Returns true for reserved identifiers used internally for elided lifetimes,
942942 /// unnamed method parameters, crate root module, error recovery etc.
943943 pub fn is_special_ident ( & self ) -> bool {
944- self . is_non_raw_ident_where ( sp:: Ident :: is_special)
944+ self . non_raw_ident ( ) . is_some_and ( sp:: Ident :: is_special)
945945 }
946946
947947 /// Returns `true` if the token is a keyword used in the language.
948948 pub fn is_used_keyword ( & self ) -> bool {
949- self . is_non_raw_ident_where ( sp:: Ident :: is_used_keyword)
949+ self . non_raw_ident ( ) . is_some_and ( sp:: Ident :: is_used_keyword)
950950 }
951951
952952 /// Returns `true` if the token is a keyword reserved for possible future use.
953953 pub fn is_unused_keyword ( & self ) -> bool {
954- self . is_non_raw_ident_where ( sp:: Ident :: is_unused_keyword)
954+ self . non_raw_ident ( ) . is_some_and ( sp:: Ident :: is_unused_keyword)
955955 }
956956
957957 /// Returns `true` if the token is either a special identifier or a keyword.
958958 pub fn is_reserved_ident ( & self ) -> bool {
959- self . is_non_raw_ident_where ( sp:: Ident :: is_reserved)
959+ self . non_raw_ident ( ) . is_some_and ( sp:: Ident :: is_reserved)
960960 }
961961
962962 pub fn is_non_reserved_ident ( & self ) -> bool {
@@ -975,7 +975,7 @@ impl Token {
975975
976976 /// Returns `true` if the token is the identifier `true` or `false`.
977977 pub fn is_bool_lit ( & self ) -> bool {
978- self . is_non_raw_ident_where ( |id| id. name . is_bool_lit ( ) )
978+ self . non_raw_ident ( ) . is_some_and ( |id| id. name . is_bool_lit ( ) )
979979 }
980980
981981 pub fn is_numeric_lit ( & self ) -> bool {
@@ -990,11 +990,11 @@ impl Token {
990990 matches ! ( self . kind, Literal ( Lit { kind: LitKind :: Integer , .. } ) )
991991 }
992992
993- /// Returns `true` if the token is a non-raw identifier for which `pred` holds .
994- pub fn is_non_raw_ident_where ( & self , pred : impl FnOnce ( sp:: Ident ) -> bool ) -> bool {
993+ /// Returns an identifier if this token is a non-raw identifier.
994+ pub fn non_raw_ident ( & self ) -> Option < sp:: Ident > {
995995 match self . ident ( ) {
996- Some ( ( id, IdentKind :: Normal | IdentKind :: ForcedKeyword ) ) => pred ( id) ,
997- _ => false ,
996+ Some ( ( id, IdentKind :: Normal | IdentKind :: ForcedKeyword ) ) => Some ( id) ,
997+ _ => None ,
998998 }
999999 }
10001000
0 commit comments