@@ -20,18 +20,26 @@ 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+ // a few 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 {
2733 // Special reserved identifiers used internally for elided lifetimes,
2834 // unnamed method parameters, crate root module, error recovery etc.
35+ // Matching predicates: `is_any_keyword`, `is_special`/`is_reserved`
2936 Empty : "" ,
3037 PathRoot : "{{root}}" ,
3138 DollarCrate : "$crate" ,
3239 Underscore : "_" ,
3340
3441 // Keywords that are used in stable Rust.
42+ // Matching predicates: `is_any_keyword`, `is_used_keyword_always`/`is_reserved`
3543 As : "as" ,
3644 Break : "break" ,
3745 Const : "const" ,
@@ -69,6 +77,7 @@ symbols! {
6977 While : "while" ,
7078
7179 // Keywords that are used in unstable Rust or reserved for future use.
80+ // Matching predicates: `is_any_keyword`, `is_unused_keyword_always`/`is_reserved`
7281 Abstract : "abstract" ,
7382 Become : "become" ,
7483 Box : "box" ,
@@ -83,19 +92,25 @@ symbols! {
8392 Yield : "yield" ,
8493
8594 // Edition-specific keywords that are used in stable Rust.
95+ // Matching predicates: `is_any_keyword`, `is_used_keyword_conditional`/`is_reserved` (if
96+ // the edition suffices)
8697 Async : "async" , // >= 2018 Edition only
8798 Await : "await" , // >= 2018 Edition only
8899 Dyn : "dyn" , // >= 2018 Edition only
89100
90101 // Edition-specific keywords that are used in unstable Rust or reserved for future use.
102+ // Matching predicates: `is_any_keyword`, `is_unused_keyword_conditional`/`is_reserved` (if
103+ // the edition suffices)
91104 Gen : "gen" , // >= 2024 Edition only
92105 Try : "try" , // >= 2018 Edition only
93106
94- // Special lifetime names
107+ // "Lifetime keywords": regular keywords with a leading `'`.
108+ // Matching predicates: `is_any_keyword`
95109 UnderscoreLifetime : "'_" ,
96110 StaticLifetime : "'static" ,
97111
98112 // Weak keywords, have special meaning only in specific contexts.
113+ // Matching predicates: `is_any_keyword`
99114 Auto : "auto" ,
100115 Builtin : "builtin" ,
101116 Catch : "catch" ,
0 commit comments