@@ -20,18 +20,25 @@ mod tests;
2020
2121// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
2222symbols ! {
23- // If you modify this list, adjust any relevant `Symbol::{is,can_be}_*` functions and
23+ // This list includes things that are definitely keywords (e.g. `if`),
24+ // things that are definitely not keywords (e.g. the empty symbol,
25+ // `{{root}}`) and things where there is disagreement between people and/or
26+ // documents (such as the Rust Reference) about whether it is a keyword
27+ // (e.g. `_`).
28+ //
29+ // If you modify this list, adjust any relevant `Symbol::{is,can_be}_*` predicates and
2430 // `used_keywords`.
2531 // But this should rarely be necessary if the keywords are kept in alphabetic order.
2632 Keywords {
27- // Special reserved identifiers used internally for elided lifetimes,
28- // unnamed method parameters, crate root module, error recovery etc.
33+ // " Special" things.
34+ // Matching predicates: `is_any_keyword`, `is_special`/`is_reserved`
2935 Empty : "" ,
3036 PathRoot : "{{root}}" ,
3137 DollarCrate : "$crate" ,
3238 Underscore : "_" ,
3339
3440 // Keywords that are used in stable Rust.
41+ // Matching predicates: `is_any_keyword`, `is_used_keyword_always`/`is_reserved`
3542 As : "as" ,
3643 Break : "break" ,
3744 Const : "const" ,
@@ -69,6 +76,7 @@ symbols! {
6976 While : "while" ,
7077
7178 // Keywords that are used in unstable Rust or reserved for future use.
79+ // Matching predicates: `is_any_keyword`, `is_unused_keyword_always`/`is_reserved`
7280 Abstract : "abstract" ,
7381 Become : "become" ,
7482 Box : "box" ,
@@ -83,19 +91,25 @@ symbols! {
8391 Yield : "yield" ,
8492
8593 // Edition-specific keywords that are used in stable Rust.
94+ // Matching predicates: `is_any_keyword`, `is_used_keyword_conditional`/`is_reserved` (if
95+ // the edition suffices)
8696 Async : "async" , // >= 2018 Edition only
8797 Await : "await" , // >= 2018 Edition only
8898 Dyn : "dyn" , // >= 2018 Edition only
8999
90100 // Edition-specific keywords that are used in unstable Rust or reserved for future use.
101+ // Matching predicates: `is_any_keyword`, `is_unused_keyword_conditional`/`is_reserved` (if
102+ // the edition suffices)
91103 Gen : "gen" , // >= 2024 Edition only
92104 Try : "try" , // >= 2018 Edition only
93105
94- // Special lifetime names
106+ // "Special" lifetime names.
107+ // Matching predicates: `is_any_keyword`, but *not* `is_special`
95108 UnderscoreLifetime : "'_" ,
96109 StaticLifetime : "'static" ,
97110
98111 // Weak keywords, have special meaning only in specific contexts.
112+ // Matching predicates: `is_any_keyword`
99113 Auto : "auto" ,
100114 Builtin : "builtin" ,
101115 Catch : "catch" ,
0 commit comments