@@ -20,18 +20,26 @@ mod tests;
20
20
21
21
// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
22
22
symbols ! {
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
24
30
// `used_keywords`.
25
31
// But this should rarely be necessary if the keywords are kept in alphabetic order.
26
32
Keywords {
27
33
// Special reserved identifiers used internally for elided lifetimes,
28
34
// unnamed method parameters, crate root module, error recovery etc.
35
+ // Matching predicates: `is_any_keyword`, `is_special`/`is_reserved`
29
36
Empty : "" ,
30
37
PathRoot : "{{root}}" ,
31
38
DollarCrate : "$crate" ,
32
39
Underscore : "_" ,
33
40
34
41
// Keywords that are used in stable Rust.
42
+ // Matching predicates: `is_any_keyword`, `is_used_keyword_always`/`is_reserved`
35
43
As : "as" ,
36
44
Break : "break" ,
37
45
Const : "const" ,
@@ -69,6 +77,7 @@ symbols! {
69
77
While : "while" ,
70
78
71
79
// Keywords that are used in unstable Rust or reserved for future use.
80
+ // Matching predicates: `is_any_keyword`, `is_unused_keyword_always`/`is_reserved`
72
81
Abstract : "abstract" ,
73
82
Become : "become" ,
74
83
Box : "box" ,
@@ -83,19 +92,25 @@ symbols! {
83
92
Yield : "yield" ,
84
93
85
94
// 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)
86
97
Async : "async" , // >= 2018 Edition only
87
98
Await : "await" , // >= 2018 Edition only
88
99
Dyn : "dyn" , // >= 2018 Edition only
89
100
90
101
// 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)
91
104
Gen : "gen" , // >= 2024 Edition only
92
105
Try : "try" , // >= 2018 Edition only
93
106
94
- // Special lifetime names
107
+ // "Lifetime keywords": regular keywords with a leading `'`.
108
+ // Matching predicates: `is_any_keyword`
95
109
UnderscoreLifetime : "'_" ,
96
110
StaticLifetime : "'static" ,
97
111
98
112
// Weak keywords, have special meaning only in specific contexts.
113
+ // Matching predicates: `is_any_keyword`
99
114
Auto : "auto" ,
100
115
Builtin : "builtin" ,
101
116
Catch : "catch" ,
0 commit comments