// The interner in thread-local, so `Symbol` shouldn't move between threads.
impl !Send for Symbol { }
+impl !Sync for Symbol { }
impl Symbol {
/// Maps a string to its interned representation.
// NB: leaving holes in the ident table is bad! a different ident will get
// interned with the id from the hole, but it will be between the min and max
// of the reserved words, and thus tagged as "reserved".
-// After modifying this list adjust `is_strict_keyword`/`is_reserved_keyword`,
+// After modifying this list adjust `is_special_ident`, `is_used_keyword`/`is_unused_keyword`,
// this should be rarely necessary though if the keywords are kept in alphabetic order.
declare_keywords! {
- // Invalid identifier
+ // Special reserved identifiers used internally for elided lifetimes,
+ // unnamed method parameters, crate root module, error recovery etc.
(0, Invalid, "")
-
- // Strict keywords used in the language.
- (1, As, "as")
- (2, Box, "box")
- (3, Break, "break")
- (4, Const, "const")
- (5, Continue, "continue")
- (6, Crate, "crate")
- (7, Else, "else")
- (8, Enum, "enum")
- (9, Extern, "extern")
- (10, False, "false")
- (11, Fn, "fn")
- (12, For, "for")
- (13, If, "if")
- (14, Impl, "impl")
- (15, In, "in")
- (16, Let, "let")
- (17, Loop, "loop")
- (18, Match, "match")
- (19, Mod, "mod")
- (20, Move, "move")
- (21, Mut, "mut")
- (22, Pub, "pub")
- (23, Ref, "ref")
- (24, Return, "return")
- (25, SelfValue, "self")
- (26, SelfType, "Self")
- (27, Static, "static")
- (28, Struct, "struct")
- (29, Super, "super")
- (30, Trait, "trait")
- (31, True, "true")
- (32, Type, "type")
- (33, Unsafe, "unsafe")
- (34, Use, "use")
- (35, Where, "where")
- (36, While, "while")
+ (1, CrateRoot, "{{root}}")
+ (2, DollarCrate, "$crate")
+
+ // Keywords used in the language.
+ (3, As, "as")
+ (4, Box, "box")
+ (5, Break, "break")
+ (6, Const, "const")
+ (7, Continue, "continue")
+ (8, Crate, "crate")
+ (9, Else, "else")
+ (10, Enum, "enum")
+ (11, Extern, "extern")
+ (12, False, "false")
+ (13, Fn, "fn")
+ (14, For, "for")
+ (15, If, "if")
+ (16, Impl, "impl")
+ (17, In, "in")
+ (18, Let, "let")
+ (19, Loop, "loop")
+ (20, Match, "match")
+ (21, Mod, "mod")
+ (22, Move, "move")
+ (23, Mut, "mut")
+ (24, Pub, "pub")
+ (25, Ref, "ref")
+ (26, Return, "return")
+ (27, SelfValue, "self")
+ (28, SelfType, "Self")
+ (29, Static, "static")
+ (30, Struct, "struct")
+ (31, Super, "super")
+ (32, Trait, "trait")
+ (33, True, "true")
+ (34, Type, "type")
+ (35, Unsafe, "unsafe")
+ (36, Use, "use")
+ (37, Where, "where")
+ (38, While, "while")
// Keywords reserved for future use.
- (37, Abstract, "abstract")
- (38, Alignof, "alignof")
- (39, Become, "become")
- (40, Do, "do")
- (41, Final, "final")
- (42, Macro, "macro")
- (43, Offsetof, "offsetof")
- (44, Override, "override")
- (45, Priv, "priv")
- (46, Proc, "proc")
- (47, Pure, "pure")
- (48, Sizeof, "sizeof")
- (49, Typeof, "typeof")
- (50, Unsized, "unsized")
- (51, Virtual, "virtual")
- (52, Yield, "yield")
+ (39, Abstract, "abstract")
+ (40, Alignof, "alignof")
+ (41, Become, "become")
+ (42, Do, "do")
+ (43, Final, "final")
+ (44, Macro, "macro")
+ (45, Offsetof, "offsetof")
+ (46, Override, "override")
+ (47, Priv, "priv")
+ (48, Proc, "proc")
+ (49, Pure, "pure")
+ (50, Sizeof, "sizeof")
+ (51, Typeof, "typeof")
+ (52, Unsized, "unsized")
+ (53, Virtual, "virtual")
+ (54, Yield, "yield")
// Weak keywords, have special meaning only in specific contexts.
- (53, Default, "default")
- (54, StaticLifetime, "'static")
- (55, Union, "union")
- (56, Catch, "catch")
-
- // A virtual keyword that resolves to the crate root when used in a lexical scope.
- (57, CrateRoot, "{{root}}")
+ (55, Default, "default")
+ (56, StaticLifetime, "'static")
+ (57, Union, "union")
+ (58, Catch, "catch")
}
// If an interner exists in TLS, return it. Otherwise, prepare a fresh one.