Skip to content

Commit 10236fb

Browse files
committed
Alphabetize the keywords list.
1 parent 3aaa12f commit 10236fb

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

compiler/rustc_span/src/symbol.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ symbols! {
2727
// (e.g. `_`).
2828
//
2929
// If you modify this list, adjust any relevant `Symbol::{is,can_be}_*`
30-
// predicates and `used_keywords`. (This should rarely be necessary if
31-
// the keywords are kept in alphabetic order.) Also consider adding new
32-
// keywords to the `ui/parser/raw/raw-idents.rs` test.
30+
// predicates and `used_keywords`. Also consider adding new keywords to the
31+
// `ui/parser/raw/raw-idents.rs` test.
3332
Keywords {
3433
// Special reserved identifiers used internally for elided lifetimes,
3534
// unnamed method parameters, crate root module, error recovery etc.
@@ -43,13 +42,16 @@ symbols! {
4342
// present, it's better to use `sym::dummy` than `kw::Empty`, because
4443
// it's clearer that it's intended as a dummy value, and more likely
4544
// to be detected if it accidentally does get used.
45+
// tidy-alphabetical-start
46+
DollarCrate: "$crate",
4647
Empty: "",
4748
PathRoot: "{{root}}",
48-
DollarCrate: "$crate",
4949
Underscore: "_",
50+
// tidy-alphabetical-end
5051

5152
// Keywords that are used in stable Rust.
5253
// Matching predicates: `is_used_keyword_always`/`is_reserved`
54+
// tidy-alphabetical-start
5355
As: "as",
5456
Break: "break",
5557
Const: "const",
@@ -85,9 +87,11 @@ symbols! {
8587
Use: "use",
8688
Where: "where",
8789
While: "while",
90+
// tidy-alphabetical-end
8891

8992
// Keywords that are used in unstable Rust or reserved for future use.
9093
// Matching predicates: `is_unused_keyword_always`/`is_reserved`
94+
// tidy-alphabetical-start
9195
Abstract: "abstract",
9296
Become: "become",
9397
Box: "box",
@@ -100,39 +104,48 @@ symbols! {
100104
Unsized: "unsized",
101105
Virtual: "virtual",
102106
Yield: "yield",
107+
// tidy-alphabetical-end
103108

104109
// Edition-specific keywords that are used in stable Rust.
105110
// Matching predicates: `is_used_keyword_conditional`/`is_reserved` (if
106111
// the edition suffices)
112+
// tidy-alphabetical-start
107113
Async: "async", // >= 2018 Edition only
108114
Await: "await", // >= 2018 Edition only
109115
Dyn: "dyn", // >= 2018 Edition only
116+
// tidy-alphabetical-end
110117

111118
// Edition-specific keywords that are used in unstable Rust or reserved for future use.
112119
// Matching predicates: `is_unused_keyword_conditional`/`is_reserved` (if
113120
// the edition suffices)
121+
// tidy-alphabetical-start
114122
Gen: "gen", // >= 2024 Edition only
115123
Try: "try", // >= 2018 Edition only
124+
// tidy-alphabetical-end
116125

117126
// "Lifetime keywords": regular keywords with a leading `'`.
118127
// Matching predicates: none
119-
UnderscoreLifetime: "'_",
128+
// tidy-alphabetical-start
120129
StaticLifetime: "'static",
130+
UnderscoreLifetime: "'_",
131+
// tidy-alphabetical-end
121132

122133
// Weak keywords, have special meaning only in specific contexts.
123134
// Matching predicates: none
135+
// tidy-alphabetical-start
124136
Auto: "auto",
125137
Builtin: "builtin",
126138
Catch: "catch",
139+
ContractEnsures: "contract_ensures",
140+
ContractRequires: "contract_requires",
127141
Default: "default",
128142
MacroRules: "macro_rules",
129143
Raw: "raw",
130144
Reuse: "reuse",
131-
ContractEnsures: "contract_ensures",
132-
ContractRequires: "contract_requires",
133145
Safe: "safe",
134146
Union: "union",
135147
Yeet: "yeet",
148+
// tidy-alphabetical-end
136149
}
137150

138151
// Pre-interned symbols that can be referred to with `rustc_span::sym::*`.
@@ -2781,7 +2794,7 @@ impl Ident {
27812794
/// *Note:* Please update this if a new keyword is added beyond the current
27822795
/// range.
27832796
pub fn used_keywords(edition: impl Copy + FnOnce() -> Edition) -> Vec<Symbol> {
2784-
(kw::Empty.as_u32()..kw::Yeet.as_u32())
2797+
(kw::DollarCrate.as_u32()..kw::Yeet.as_u32())
27852798
.filter_map(|kw| {
27862799
let kw = Symbol::new(kw);
27872800
if kw.is_used_keyword_always() || kw.is_used_keyword_conditional(edition) {

0 commit comments

Comments
 (0)