@@ -20,18 +20,25 @@ 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
+ // 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
- // 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`
29
35
Empty : "" ,
30
36
PathRoot : "{{root}}" ,
31
37
DollarCrate : "$crate" ,
32
38
Underscore : "_" ,
33
39
34
40
// Keywords that are used in stable Rust.
41
+ // Matching predicates: `is_any_keyword`, `is_used_keyword_always`/`is_reserved`
35
42
As : "as" ,
36
43
Break : "break" ,
37
44
Const : "const" ,
@@ -69,6 +76,7 @@ symbols! {
69
76
While : "while" ,
70
77
71
78
// Keywords that are used in unstable Rust or reserved for future use.
79
+ // Matching predicates: `is_any_keyword`, `is_unused_keyword_always`/`is_reserved`
72
80
Abstract : "abstract" ,
73
81
Become : "become" ,
74
82
Box : "box" ,
@@ -83,19 +91,25 @@ symbols! {
83
91
Yield : "yield" ,
84
92
85
93
// 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)
86
96
Async : "async" , // >= 2018 Edition only
87
97
Await : "await" , // >= 2018 Edition only
88
98
Dyn : "dyn" , // >= 2018 Edition only
89
99
90
100
// 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)
91
103
Gen : "gen" , // >= 2024 Edition only
92
104
Try : "try" , // >= 2018 Edition only
93
105
94
- // Special lifetime names
106
+ // "Special" lifetime names.
107
+ // Matching predicates: `is_any_keyword`, but *not* `is_special`
95
108
UnderscoreLifetime : "'_" ,
96
109
StaticLifetime : "'static" ,
97
110
98
111
// Weak keywords, have special meaning only in specific contexts.
112
+ // Matching predicates: `is_any_keyword`
99
113
Auto : "auto" ,
100
114
Builtin : "builtin" ,
101
115
Catch : "catch" ,
0 commit comments