Improve comments on Keywords
.
In particular, clarify which predicates apply to which keywords.
This commit is contained in:
parent
ed5b91abc8
commit
6de550cc68
1 changed files with 17 additions and 2 deletions
|
@ -20,18 +20,26 @@ mod tests;
|
||||||
|
|
||||||
// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
|
// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
|
||||||
symbols! {
|
symbols! {
|
||||||
// If you modify this list, adjust any relevant `Symbol::{is,can_be}_*` functions and
|
// This list includes things that are definitely keywords (e.g. `if`),
|
||||||
|
// a few things that are definitely not keywords (e.g. the empty symbol,
|
||||||
|
// `{{root}}`) and things where there is disagreement between people and/or
|
||||||
|
// documents (such as the Rust Reference) about whether it is a keyword
|
||||||
|
// (e.g. `_`).
|
||||||
|
//
|
||||||
|
// If you modify this list, adjust any relevant `Symbol::{is,can_be}_*` predicates and
|
||||||
// `used_keywords`.
|
// `used_keywords`.
|
||||||
// But this should rarely be necessary if the keywords are kept in alphabetic order.
|
// But this should rarely be necessary if the keywords are kept in alphabetic order.
|
||||||
Keywords {
|
Keywords {
|
||||||
// Special reserved identifiers used internally for elided lifetimes,
|
// Special reserved identifiers used internally for elided lifetimes,
|
||||||
// unnamed method parameters, crate root module, error recovery etc.
|
// unnamed method parameters, crate root module, error recovery etc.
|
||||||
|
// Matching predicates: `is_any_keyword`, `is_special`/`is_reserved`
|
||||||
Empty: "",
|
Empty: "",
|
||||||
PathRoot: "{{root}}",
|
PathRoot: "{{root}}",
|
||||||
DollarCrate: "$crate",
|
DollarCrate: "$crate",
|
||||||
Underscore: "_",
|
Underscore: "_",
|
||||||
|
|
||||||
// Keywords that are used in stable Rust.
|
// Keywords that are used in stable Rust.
|
||||||
|
// Matching predicates: `is_any_keyword`, `is_used_keyword_always`/`is_reserved`
|
||||||
As: "as",
|
As: "as",
|
||||||
Break: "break",
|
Break: "break",
|
||||||
Const: "const",
|
Const: "const",
|
||||||
|
@ -69,6 +77,7 @@ symbols! {
|
||||||
While: "while",
|
While: "while",
|
||||||
|
|
||||||
// Keywords that are used in unstable Rust or reserved for future use.
|
// Keywords that are used in unstable Rust or reserved for future use.
|
||||||
|
// Matching predicates: `is_any_keyword`, `is_unused_keyword_always`/`is_reserved`
|
||||||
Abstract: "abstract",
|
Abstract: "abstract",
|
||||||
Become: "become",
|
Become: "become",
|
||||||
Box: "box",
|
Box: "box",
|
||||||
|
@ -83,19 +92,25 @@ symbols! {
|
||||||
Yield: "yield",
|
Yield: "yield",
|
||||||
|
|
||||||
// Edition-specific keywords that are used in stable Rust.
|
// Edition-specific keywords that are used in stable Rust.
|
||||||
|
// Matching predicates: `is_any_keyword`, `is_used_keyword_conditional`/`is_reserved` (if
|
||||||
|
// the edition suffices)
|
||||||
Async: "async", // >= 2018 Edition only
|
Async: "async", // >= 2018 Edition only
|
||||||
Await: "await", // >= 2018 Edition only
|
Await: "await", // >= 2018 Edition only
|
||||||
Dyn: "dyn", // >= 2018 Edition only
|
Dyn: "dyn", // >= 2018 Edition only
|
||||||
|
|
||||||
// Edition-specific keywords that are used in unstable Rust or reserved for future use.
|
// Edition-specific keywords that are used in unstable Rust or reserved for future use.
|
||||||
|
// Matching predicates: `is_any_keyword`, `is_unused_keyword_conditional`/`is_reserved` (if
|
||||||
|
// the edition suffices)
|
||||||
Gen: "gen", // >= 2024 Edition only
|
Gen: "gen", // >= 2024 Edition only
|
||||||
Try: "try", // >= 2018 Edition only
|
Try: "try", // >= 2018 Edition only
|
||||||
|
|
||||||
// Special lifetime names
|
// "Lifetime keywords": regular keywords with a leading `'`.
|
||||||
|
// Matching predicates: `is_any_keyword`
|
||||||
UnderscoreLifetime: "'_",
|
UnderscoreLifetime: "'_",
|
||||||
StaticLifetime: "'static",
|
StaticLifetime: "'static",
|
||||||
|
|
||||||
// Weak keywords, have special meaning only in specific contexts.
|
// Weak keywords, have special meaning only in specific contexts.
|
||||||
|
// Matching predicates: `is_any_keyword`
|
||||||
Auto: "auto",
|
Auto: "auto",
|
||||||
Builtin: "builtin",
|
Builtin: "builtin",
|
||||||
Catch: "catch",
|
Catch: "catch",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue