]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_span/src/symbol.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_span / src / symbol.rs
CommitLineData
476ff2be 1//! An "interner" is a data structure that associates values with usize tags and
0731742a 2//! allows bidirectional lookup; i.e., given a value, one can easily find the
476ff2be
SL
3//! type, and vice versa.
4
f035d41b 5use rustc_arena::DroplessArena;
0731742a 6use rustc_data_structures::fx::FxHashMap;
dfeec247 7use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
c295e0f8 8use rustc_data_structures::sync::Lock;
3dfed10e 9use rustc_macros::HashStable_Generic;
416331ca 10use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
0731742a 11
dfeec247 12use std::cmp::{Ord, PartialEq, PartialOrd};
dc9dc135 13use std::fmt;
83c7162d 14use std::hash::{Hash, Hasher};
dc9dc135 15use std::str;
476ff2be 16
136023e0 17use crate::{with_session_globals, Edition, Span, DUMMY_SP};
0731742a 18
416331ca
XL
19#[cfg(test)]
20mod tests;
21
6a06907d 22// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
48663c56
XL
23symbols! {
24 // After modifying this list adjust `is_special`, `is_used_keyword`/`is_unused_keyword`,
25 // this should be rarely necessary though if the keywords are kept in alphabetic order.
26 Keywords {
27 // Special reserved identifiers used internally for elided lifetimes,
28 // unnamed method parameters, crate root module, error recovery etc.
5869c6ff 29 Empty: "",
48663c56
XL
30 PathRoot: "{{root}}",
31 DollarCrate: "$crate",
32 Underscore: "_",
33
34 // Keywords that are used in stable Rust.
35 As: "as",
36 Break: "break",
37 Const: "const",
38 Continue: "continue",
39 Crate: "crate",
40 Else: "else",
41 Enum: "enum",
42 Extern: "extern",
43 False: "false",
44 Fn: "fn",
45 For: "for",
46 If: "if",
47 Impl: "impl",
48 In: "in",
49 Let: "let",
50 Loop: "loop",
51 Match: "match",
52 Mod: "mod",
53 Move: "move",
54 Mut: "mut",
55 Pub: "pub",
56 Ref: "ref",
57 Return: "return",
58 SelfLower: "self",
59 SelfUpper: "Self",
60 Static: "static",
61 Struct: "struct",
62 Super: "super",
63 Trait: "trait",
64 True: "true",
65 Type: "type",
66 Unsafe: "unsafe",
67 Use: "use",
68 Where: "where",
69 While: "while",
70
71 // Keywords that are used in unstable Rust or reserved for future use.
72 Abstract: "abstract",
73 Become: "become",
74 Box: "box",
75 Do: "do",
76 Final: "final",
77 Macro: "macro",
78 Override: "override",
79 Priv: "priv",
80 Typeof: "typeof",
81 Unsized: "unsized",
82 Virtual: "virtual",
83 Yield: "yield",
84
85 // Edition-specific keywords that are used in stable Rust.
e1599b0c
XL
86 Async: "async", // >= 2018 Edition only
87 Await: "await", // >= 2018 Edition only
48663c56
XL
88 Dyn: "dyn", // >= 2018 Edition only
89
90 // Edition-specific keywords that are used in unstable Rust or reserved for future use.
48663c56
XL
91 Try: "try", // >= 2018 Edition only
92
93 // Special lifetime names
94 UnderscoreLifetime: "'_",
95 StaticLifetime: "'static",
96
97 // Weak keywords, have special meaning only in specific contexts.
98 Auto: "auto",
99 Catch: "catch",
100 Default: "default",
74b04a01 101 MacroRules: "macro_rules",
60c5eb7d 102 Raw: "raw",
48663c56
XL
103 Union: "union",
104 }
105
3dfed10e
XL
106 // Pre-interned symbols that can be referred to with `rustc_span::sym::*`.
107 //
108 // The symbol is the stringified identifier unless otherwise specified, in
109 // which case the name should mention the non-identifier punctuation.
110 // E.g. `sym::proc_dash_macro` represents "proc-macro", and it shouldn't be
111 // called `sym::proc_macro` because then it's easy to mistakenly think it
112 // represents "proc_macro".
dc9dc135 113 //
1b1a35ee 114 // As well as the symbols listed, there are symbols for the strings
dc9dc135 115 // "0", "1", ..., "9", which are accessible via `sym::integer`.
3dfed10e
XL
116 //
117 // The proc macro will abort if symbols are not in alphabetical order (as
118 // defined by `impl Ord for str`) or if any symbols are duplicated. Vim
119 // users can sort the list by selecting it and executing the command
120 // `:'<,'>!LC_ALL=C sort`.
121 //
122 // There is currently no checking that all symbols are used; that would be
123 // nice to have.
48663c56 124 Symbols {
94222f64
XL
125 AcqRel,
126 Acquire,
3dfed10e 127 Alignment,
136023e0 128 Any,
3dfed10e
XL
129 Arc,
130 Argument,
131 ArgumentV1,
132 Arguments,
136023e0
XL
133 AsMut,
134 AsRef,
94222f64
XL
135 AtomicBool,
136 AtomicI128,
137 AtomicI16,
138 AtomicI32,
139 AtomicI64,
140 AtomicI8,
141 AtomicIsize,
142 AtomicPtr,
143 AtomicU128,
144 AtomicU16,
145 AtomicU32,
146 AtomicU64,
147 AtomicU8,
148 AtomicUsize,
136023e0 149 BTreeEntry,
6a06907d
XL
150 BTreeMap,
151 BTreeSet,
152 BinaryHeap,
153 Borrow,
17df50a5 154 Break,
3dfed10e 155 C,
17df50a5 156 CStr,
29967ef6 157 CString,
3dfed10e
XL
158 Center,
159 Clone,
17df50a5 160 Continue,
3dfed10e
XL
161 Copy,
162 Count,
136023e0 163 Cow,
3dfed10e 164 Debug,
5869c6ff
XL
165 DebugStruct,
166 DebugTuple,
3dfed10e
XL
167 Decodable,
168 Decoder,
169 Default,
6a06907d 170 Deref,
136023e0 171 DirBuilder,
c295e0f8 172 Display,
136023e0
XL
173 DoubleEndedIterator,
174 Duration,
3dfed10e
XL
175 Encodable,
176 Encoder,
177 Eq,
178 Equal,
179 Err,
180 Error,
136023e0
XL
181 File,
182 FileType,
3dfed10e
XL
183 FormatSpec,
184 Formatter,
185 From,
136023e0 186 FromIterator,
5099ac24 187 FromResidual,
3dfed10e
XL
188 Future,
189 FxHashMap,
190 FxHashSet,
191 GlobalAlloc,
192 Hash,
193 HashMap,
136023e0 194 HashMapEntry,
3dfed10e
XL
195 HashSet,
196 Hasher,
197 Implied,
198 Input,
c295e0f8 199 Into,
a2a8927a 200 IntoFuture,
3dfed10e 201 IntoIterator,
136023e0
XL
202 IoRead,
203 IoWrite,
3dfed10e
XL
204 Is,
205 ItemContext,
206 Iterator,
207 Layout,
208 Left,
6a06907d 209 LinkedList,
3dfed10e 210 LintPass,
c295e0f8 211 Mutex,
5099ac24 212 N,
3dfed10e
XL
213 None,
214 Ok,
215 Option,
216 Ord,
217 Ordering,
6a06907d
XL
218 OsStr,
219 OsString,
3dfed10e
XL
220 Output,
221 Param,
222 PartialEq,
223 PartialOrd,
6a06907d
XL
224 Path,
225 PathBuf,
3dfed10e
XL
226 Pending,
227 Pin,
c295e0f8 228 Pointer,
3dfed10e
XL
229 Poll,
230 ProcMacro,
231 ProcMacroHack,
232 ProceduralMasqueradeDummyType,
233 Range,
234 RangeFrom,
235 RangeFull,
236 RangeInclusive,
237 RangeTo,
238 RangeToInclusive,
239 Rc,
240 Ready,
6a06907d 241 Receiver,
94222f64
XL
242 Relaxed,
243 Release,
3dfed10e
XL
244 Result,
245 Return,
246 Right,
247 RustcDecodable,
248 RustcEncodable,
249 Send,
94222f64 250 SeqCst,
3dfed10e 251 Some,
c295e0f8 252 String,
3dfed10e
XL
253 StructuralEq,
254 StructuralPartialEq,
255 Sync,
256 Target,
6a06907d
XL
257 ToOwned,
258 ToString,
3dfed10e 259 Try,
c295e0f8
XL
260 TryFrom,
261 TryInto,
3dfed10e
XL
262 Ty,
263 TyCtxt,
264 TyKind,
265 Unknown,
c295e0f8 266 UnsafeArg,
3dfed10e 267 Vec,
c295e0f8 268 VecDeque,
3dfed10e
XL
269 Yield,
270 _DECLS,
271 _Self,
272 __D,
273 __H,
274 __S,
5e7ed085 275 __awaitee,
3dfed10e
XL
276 __try_var,
277 _d,
278 _e,
279 _task_context,
29967ef6 280 a32,
48663c56 281 aarch64_target_feature,
5e7ed085 282 aarch64_ver_target_feature,
48663c56
XL
283 abi,
284 abi_amdgpu_kernel,
3dfed10e 285 abi_avr_interrupt,
5869c6ff 286 abi_c_cmse_nonsecure_call,
e74abb32 287 abi_efiapi,
48663c56
XL
288 abi_msp430_interrupt,
289 abi_ptx,
290 abi_sysv64,
291 abi_thiscall,
292 abi_unadjusted,
293 abi_vectorcall,
294 abi_x86_interrupt,
ba9703b0 295 abort,
48663c56 296 aborts,
3dfed10e
XL
297 add,
298 add_assign,
60c5eb7d 299 add_with_overflow,
3dfed10e 300 address,
94222f64 301 adt_const_params,
48663c56
XL
302 advanced_slice_patterns,
303 adx_target_feature,
304 alias,
305 align,
3dfed10e 306 align_offset,
48663c56
XL
307 alignstack,
308 all,
3dfed10e
XL
309 alloc,
310 alloc_error_handler,
311 alloc_layout,
312 alloc_zeroed,
48663c56 313 allocator,
3c0e092e 314 allocator_api,
48663c56 315 allocator_internals,
48663c56 316 allow,
48663c56
XL
317 allow_fail,
318 allow_internal_unsafe,
319 allow_internal_unstable,
3dfed10e 320 allowed,
5099ac24 321 alu32,
48663c56 322 always,
dc9dc135 323 and,
3dfed10e 324 and_then,
48663c56 325 any,
5099ac24 326 append_const_msg,
dc9dc135 327 arbitrary_enum_discriminant,
48663c56 328 arbitrary_self_types,
5099ac24 329 args,
f9f354fc 330 arith_offset,
29967ef6 331 arm,
48663c56 332 arm_target_feature,
3dfed10e
XL
333 array,
334 arrays,
29967ef6 335 as_ptr,
5099ac24 336 as_ref,
3dfed10e 337 as_str,
48663c56 338 asm,
3c0e092e
XL
339 asm_const,
340 asm_experimental_arch,
341 asm_sym,
a2a8927a 342 asm_unwind,
416331ca 343 assert,
5099ac24 344 assert_eq_macro,
f035d41b 345 assert_inhabited,
fc512014 346 assert_macro,
5099ac24 347 assert_ne_macro,
3dfed10e 348 assert_receiver_is_total_eq,
f035d41b
XL
349 assert_uninit_valid,
350 assert_zero_valid,
5099ac24 351 associated_const_equality,
48663c56 352 associated_consts,
dc9dc135 353 associated_type_bounds,
48663c56
XL
354 associated_type_defaults,
355 associated_types,
f035d41b 356 assume,
60c5eb7d 357 assume_init,
48663c56 358 async_await,
416331ca 359 async_closure,
94222f64
XL
360 atomic,
361 atomic_mod,
f035d41b 362 atomics,
3dfed10e 363 att_syntax,
48663c56 364 attr,
48663c56 365 attr_literals,
3dfed10e 366 attributes,
48663c56 367 augmented_assignments,
fc512014 368 auto_traits,
48663c56 369 automatically_derived,
5099ac24 370 avx,
48663c56 371 avx512_target_feature,
5099ac24
FG
372 avx512bw,
373 avx512f,
48663c56 374 await_macro,
3dfed10e 375 bang,
dc9dc135
XL
376 begin_panic,
377 bench,
48663c56
XL
378 bin,
379 bind_by_move_pattern_guards,
dfeec247 380 bindings_after_at,
3dfed10e
XL
381 bitand,
382 bitand_assign,
383 bitor,
384 bitor_assign,
385 bitreverse,
386 bitxor,
387 bitxor_assign,
94222f64 388 black_box,
48663c56 389 block,
dc9dc135 390 bool,
dfeec247 391 borrowck_graphviz_format,
48663c56
XL
392 borrowck_graphviz_postflow,
393 borrowck_graphviz_preflow,
3dfed10e 394 box_free,
48663c56
XL
395 box_patterns,
396 box_syntax,
17df50a5 397 bpf_target_feature,
48663c56 398 braced_empty_structs,
17df50a5 399 branch,
f035d41b 400 breakpoint,
3dfed10e 401 bridge,
60c5eb7d 402 bswap,
29967ef6 403 c_str,
6a06907d 404 c_unwind,
3dfed10e
XL
405 c_variadic,
406 call,
407 call_mut,
408 call_once,
60c5eb7d 409 caller_location,
fc512014 410 capture_disjoint_fields,
48663c56 411 cdylib,
f035d41b
XL
412 ceilf32,
413 ceilf64,
48663c56 414 cfg,
ba9703b0 415 cfg_accessible,
48663c56
XL
416 cfg_attr,
417 cfg_attr_multi,
416331ca 418 cfg_doctest,
6a06907d 419 cfg_eval,
c295e0f8 420 cfg_hide,
5099ac24 421 cfg_macro,
29967ef6 422 cfg_panic,
60c5eb7d 423 cfg_sanitize,
136023e0 424 cfg_target_abi,
48663c56
XL
425 cfg_target_feature,
426 cfg_target_has_atomic,
5099ac24
FG
427 cfg_target_has_atomic_equal_alignment,
428 cfg_target_has_atomic_load_store,
48663c56
XL
429 cfg_target_thread_local,
430 cfg_target_vendor,
f9f354fc 431 cfg_version,
3c0e092e 432 cfi,
dc9dc135 433 char,
3dfed10e 434 client,
416331ca 435 clippy,
94222f64 436 clobber_abi,
48663c56
XL
437 clone,
438 clone_closures,
439 clone_from,
1b1a35ee 440 closure,
48663c56 441 closure_to_fn_coercion,
c295e0f8 442 closure_track_caller,
dc9dc135 443 cmp,
136023e0
XL
444 cmp_max,
445 cmp_min,
48663c56 446 cmpxchg16b_target_feature,
1b1a35ee 447 cmse_nonsecure_entry,
3dfed10e 448 coerce_unsized,
48663c56 449 cold,
416331ca 450 column,
5099ac24 451 column_macro,
94222f64
XL
452 compare_and_swap,
453 compare_exchange,
454 compare_exchange_weak,
48663c56 455 compile_error,
5099ac24
FG
456 compile_error_macro,
457 compiler,
48663c56 458 compiler_builtins,
94222f64 459 compiler_fence,
416331ca 460 concat,
a2a8927a 461 concat_bytes,
48663c56 462 concat_idents,
5099ac24 463 concat_macro,
48663c56
XL
464 conservative_impl_trait,
465 console,
fc512014 466 const_allocate,
17df50a5 467 const_async_blocks,
48663c56 468 const_compare_raw_pointers,
dc9dc135 469 const_constructor,
5099ac24 470 const_deallocate,
74b04a01 471 const_eval_limit,
c295e0f8
XL
472 const_eval_select,
473 const_eval_select_ct,
1b1a35ee 474 const_evaluatable_checked,
e74abb32 475 const_extern_fn,
48663c56 476 const_fn,
1b1a35ee
XL
477 const_fn_floating_point_arithmetic,
478 const_fn_fn_ptr_basics,
cdc7bbd5 479 const_fn_trait_bound,
f035d41b 480 const_fn_transmute,
48663c56 481 const_fn_union,
cdc7bbd5 482 const_fn_unsize,
94222f64
XL
483 const_for,
484 const_format_args,
cdc7bbd5 485 const_generic_defaults,
48663c56 486 const_generics,
5869c6ff 487 const_generics_defaults,
60c5eb7d 488 const_if_match,
29967ef6 489 const_impl_trait,
416331ca 490 const_in_array_repeat_expressions,
3dfed10e 491 const_indexing,
48663c56 492 const_let,
60c5eb7d
XL
493 const_loop,
494 const_mut_refs,
48663c56 495 const_panic,
94222f64 496 const_panic_fmt,
f035d41b 497 const_precise_live_drops,
48663c56
XL
498 const_raw_ptr_deref,
499 const_raw_ptr_to_usize_cast,
5869c6ff 500 const_refs_to_cell,
dfeec247
XL
501 const_trait_bound_opt_out,
502 const_trait_impl,
3dfed10e 503 const_transmute,
94222f64 504 const_try,
1b1a35ee
XL
505 constant,
506 constructor,
48663c56 507 contents,
dc9dc135 508 context,
48663c56 509 convert,
f035d41b 510 copy,
3dfed10e 511 copy_closures,
f035d41b
XL
512 copy_nonoverlapping,
513 copysignf32,
514 copysignf64,
48663c56
XL
515 core,
516 core_intrinsics,
5869c6ff
XL
517 core_panic,
518 core_panic_2015_macro,
fc512014 519 core_panic_macro,
f035d41b
XL
520 cosf32,
521 cosf64,
a2a8927a 522 count,
94222f64 523 cr,
48663c56
XL
524 crate_id,
525 crate_in_paths,
dc9dc135 526 crate_local,
48663c56
XL
527 crate_name,
528 crate_type,
529 crate_visibility_modifier,
3dfed10e 530 crt_dash_static: "crt-static",
29967ef6 531 cstring_type,
3dfed10e
XL
532 ctlz,
533 ctlz_nonzero,
60c5eb7d
XL
534 ctpop,
535 cttz,
536 cttz_nonzero,
48663c56
XL
537 custom_attribute,
538 custom_derive,
539 custom_inner_attributes,
540 custom_test_frameworks,
3dfed10e 541 d,
5e7ed085 542 d32,
5099ac24 543 dbg_macro,
3dfed10e
XL
544 dead_code,
545 dealloc,
546 debug,
5099ac24 547 debug_assert_eq_macro,
fc512014 548 debug_assert_macro,
5099ac24 549 debug_assert_ne_macro,
3dfed10e
XL
550 debug_assertions,
551 debug_struct,
3dfed10e
XL
552 debug_trait_builder,
553 debug_tuple,
48663c56 554 decl_macro,
3dfed10e
XL
555 declare_lint_pass,
556 decode,
29967ef6 557 default_alloc_error_handler,
48663c56 558 default_lib_allocator,
136023e0 559 default_method_body_is_const,
48663c56
XL
560 default_type_parameter_fallback,
561 default_type_params,
60c5eb7d 562 delay_span_bug_from_inside_query,
48663c56
XL
563 deny,
564 deprecated,
5e7ed085
FG
565 deprecated_safe,
566 deprecated_suggestion,
dc9dc135 567 deref,
1b1a35ee 568 deref_method,
dc9dc135 569 deref_mut,
1b1a35ee 570 deref_target,
48663c56 571 derive,
94222f64 572 derive_default_enum,
5e7ed085 573 destruct,
29967ef6 574 destructuring_assignment,
e1599b0c 575 diagnostic,
dc9dc135 576 direct,
3dfed10e
XL
577 discriminant_kind,
578 discriminant_type,
ba9703b0 579 discriminant_value,
3dfed10e 580 dispatch_from_dyn,
136023e0 581 display_trait,
3dfed10e
XL
582 div,
583 div_assign,
48663c56
XL
584 doc,
585 doc_alias,
c295e0f8 586 doc_auto_cfg,
48663c56 587 doc_cfg,
c295e0f8 588 doc_cfg_hide,
48663c56
XL
589 doc_keyword,
590 doc_masked,
cdc7bbd5 591 doc_notable_trait,
94222f64 592 doc_primitive,
3dfed10e 593 doc_spotlight,
416331ca 594 doctest,
48663c56 595 document_private_items,
5099ac24 596 dotdot: "..",
48663c56 597 dotdot_in_tuple_patterns,
3dfed10e 598 dotdoteq_in_patterns,
fc512014
XL
599 dreg,
600 dreg_low16,
601 dreg_low8,
3dfed10e
XL
602 drop,
603 drop_in_place,
604 drop_types_in_const,
48663c56
XL
605 dropck_eyepatch,
606 dropck_parametricity,
48663c56 607 dylib,
6a06907d 608 dyn_metadata,
48663c56 609 dyn_trait,
5099ac24 610 e,
5869c6ff 611 edition_macro_pats,
dc3f5686 612 edition_panic,
3dfed10e 613 eh_catch_typeinfo,
48663c56 614 eh_personality,
3dfed10e
XL
615 emit_enum,
616 emit_enum_variant,
617 emit_enum_variant_arg,
618 emit_struct,
619 emit_struct_field,
48663c56 620 enable,
3dfed10e
XL
621 enclosing_scope,
622 encode,
5099ac24 623 end,
416331ca 624 env,
5099ac24
FG
625 env_macro,
626 eprint_macro,
627 eprintln_macro,
dc9dc135 628 eq,
29967ef6 629 ermsb_target_feature,
f035d41b 630 exact_div,
48663c56 631 except,
3dfed10e 632 exchange_malloc,
48663c56
XL
633 exclusive_range_pattern,
634 exhaustive_integer_patterns,
635 exhaustive_patterns,
636 existential_type,
f035d41b
XL
637 exp2f32,
638 exp2f64,
29967ef6 639 expect,
48663c56 640 expected,
3dfed10e
XL
641 expf32,
642 expf64,
94222f64 643 explicit_generic_args_with_impl_trait,
48663c56 644 export_name,
dc9dc135 645 expr,
fc512014 646 extended_key_value_attributes,
48663c56 647 extern_absolute_paths,
48663c56
XL
648 extern_crate_item_prelude,
649 extern_crate_self,
650 extern_in_paths,
651 extern_prelude,
652 extern_types,
3dfed10e
XL
653 external_doc,
654 f,
48663c56 655 f16c_target_feature,
dc9dc135
XL
656 f32,
657 f64,
f035d41b
XL
658 fabsf32,
659 fabsf64,
3dfed10e 660 fadd_fast,
f035d41b 661 fdiv_fast,
48663c56 662 feature,
94222f64 663 fence,
a2a8927a 664 ferris: "🦀",
94222f64 665 fetch_update,
29967ef6 666 ffi,
f9f354fc
XL
667 ffi_const,
668 ffi_pure,
48663c56 669 ffi_returns_twice,
dc9dc135 670 field,
48663c56
XL
671 field_init_shorthand,
672 file,
5099ac24 673 file_macro,
3dfed10e
XL
674 fill,
675 finish,
676 flags,
5099ac24 677 float,
f035d41b 678 float_to_int_unchecked,
f035d41b 679 floorf32,
3dfed10e 680 floorf64,
f035d41b
XL
681 fmaf32,
682 fmaf64,
dc9dc135 683 fmt,
94222f64 684 fmt_as_str,
dc9dc135 685 fmt_internals,
f035d41b 686 fmul_fast,
136023e0 687 fn_align,
48663c56 688 fn_must_use,
3dfed10e
XL
689 fn_mut,
690 fn_once,
691 fn_once_output,
48663c56 692 forbid,
f035d41b 693 forget,
3dfed10e 694 format,
416331ca 695 format_args,
f035d41b 696 format_args_capture,
5099ac24 697 format_args_macro,
3dfed10e 698 format_args_nl,
6a06907d 699 format_macro,
5099ac24 700 fp,
3dfed10e 701 freeze,
fc512014 702 freg,
f035d41b 703 frem_fast,
48663c56 704 from,
dc9dc135 705 from_desugaring,
48663c56 706 from_generator,
136023e0 707 from_iter,
dc9dc135 708 from_method,
17df50a5
XL
709 from_output,
710 from_residual,
3dfed10e 711 from_size_align_unchecked,
3dfed10e 712 from_usize,
f035d41b 713 fsub_fast,
48663c56
XL
714 fundamental,
715 future,
3dfed10e
XL
716 future_trait,
717 ge,
48663c56 718 gen_future,
dfeec247 719 gen_kill,
3dfed10e 720 generator,
3c0e092e 721 generator_return,
3dfed10e 722 generator_state,
48663c56 723 generators,
94222f64 724 generic_arg_infer,
48663c56 725 generic_associated_types,
5e7ed085 726 generic_associated_types_extended,
94222f64 727 generic_const_exprs,
48663c56 728 generic_param_attrs,
ba9703b0 729 get_context,
48663c56
XL
730 global_allocator,
731 global_asm,
732 globs,
3dfed10e 733 gt,
dfeec247 734 half_open_range_patterns,
dc9dc135 735 hash,
48663c56
XL
736 hexagon_target_feature,
737 hidden,
738 homogeneous_aggregate,
739 html_favicon_url,
740 html_logo_url,
741 html_no_source,
742 html_playground_url,
743 html_root_url,
6a06907d 744 hwaddress,
3dfed10e 745 i,
48663c56
XL
746 i128,
747 i128_type,
748 i16,
749 i32,
750 i64,
751 i8,
752 ident,
753 if_let,
3dfed10e 754 if_let_guard,
48663c56
XL
755 if_while_or_patterns,
756 ignore,
757 impl_header_lifetime_elision,
416331ca 758 impl_lint_pass,
3dfed10e 759 impl_macros,
48663c56
XL
760 impl_trait_in_bindings,
761 import_shadowing,
cdc7bbd5 762 imported_main,
48663c56
XL
763 in_band_lifetimes,
764 include,
416331ca 765 include_bytes,
5099ac24
FG
766 include_bytes_macro,
767 include_macro,
416331ca 768 include_str,
5099ac24 769 include_str_macro,
48663c56 770 inclusive_range_syntax,
3dfed10e
XL
771 index,
772 index_mut,
48663c56
XL
773 infer_outlives_requirements,
774 infer_static_outlives_requirements,
6a06907d 775 inherent_associated_types,
3dfed10e 776 inlateout,
48663c56 777 inline,
29967ef6 778 inline_const,
3c0e092e 779 inline_const_pat,
3dfed10e 780 inout,
29967ef6 781 instruction_set,
5099ac24
FG
782 integer_: "integer",
783 integral,
48663c56 784 intel,
a2a8927a 785 into_future,
48663c56 786 into_iter,
5869c6ff 787 intra_doc_pointers,
48663c56
XL
788 intrinsics,
789 irrefutable_let_patterns,
29967ef6 790 isa_attribute,
48663c56
XL
791 isize,
792 issue,
793 issue_5723_bootstrap,
794 issue_tracker_base_url,
dc9dc135 795 item,
48663c56
XL
796 item_like_imports,
797 iter,
136023e0 798 iter_repeat,
48663c56
XL
799 keyword,
800 kind,
fc512014 801 kreg,
48663c56
XL
802 label,
803 label_break_value,
804 lang,
805 lang_items,
cdc7bbd5 806 large_assignments,
f9f354fc 807 lateout,
3dfed10e
XL
808 lazy_normalization_consts,
809 le,
136023e0 810 len,
dc9dc135 811 let_chains,
94222f64 812 let_else,
dc9dc135 813 lhs,
48663c56 814 lib,
3dfed10e 815 libc,
dc9dc135 816 lifetime,
f035d41b 817 likely,
416331ca 818 line,
5099ac24 819 line_macro,
48663c56 820 link,
48663c56
XL
821 link_args,
822 link_cfg,
823 link_llvm_intrinsics,
824 link_name,
e74abb32 825 link_ordinal,
48663c56 826 link_section,
3dfed10e 827 linkage,
5099ac24 828 linker,
48663c56 829 lint_reasons,
dc9dc135 830 literal,
94222f64 831 load,
a2a8927a 832 loaded_from_disk,
fc512014 833 local,
48663c56 834 local_inner_macros,
f035d41b
XL
835 log10f32,
836 log10f64,
837 log2f32,
838 log2f64,
3dfed10e
XL
839 log_syntax,
840 logf32,
841 logf64,
48663c56 842 loop_break_value,
3dfed10e 843 lt,
48663c56 844 macro_at_most_once_rep,
6a06907d 845 macro_attributes_in_derive_output,
48663c56
XL
846 macro_escape,
847 macro_export,
848 macro_lifetime_matcher,
849 macro_literal_matcher,
5e7ed085 850 macro_metavar_expr,
48663c56 851 macro_reexport,
48663c56
XL
852 macro_use,
853 macro_vis_matcher,
3dfed10e 854 macros_in_extern,
48663c56
XL
855 main,
856 managed_boxes,
3dfed10e
XL
857 manually_drop,
858 map,
48663c56
XL
859 marker,
860 marker_trait_attr,
861 masked,
862 match_beginning_vert,
863 match_default_bindings,
5099ac24 864 matches_macro,
3dfed10e
XL
865 maxnumf32,
866 maxnumf64,
48663c56 867 may_dangle,
a2a8927a 868 may_unwind,
3dfed10e 869 maybe_uninit,
60c5eb7d
XL
870 maybe_uninit_uninit,
871 maybe_uninit_zeroed,
136023e0
XL
872 mem_discriminant,
873 mem_drop,
874 mem_forget,
875 mem_replace,
876 mem_size_of,
877 mem_size_of_val,
60c5eb7d 878 mem_uninitialized,
c295e0f8 879 mem_variant_count,
60c5eb7d 880 mem_zeroed,
dc9dc135 881 member_constraints,
74b04a01 882 memory,
5099ac24 883 memtag,
48663c56
XL
884 message,
885 meta,
6a06907d 886 metadata_type,
60c5eb7d 887 min_align_of,
f035d41b 888 min_align_of_val,
48663c56 889 min_const_fn,
3dfed10e 890 min_const_generics,
48663c56 891 min_const_unsafe_fn,
ba9703b0 892 min_specialization,
6a06907d 893 min_type_alias_impl_trait,
f035d41b
XL
894 minnumf32,
895 minnumf64,
48663c56 896 mips_target_feature,
5e7ed085 897 miri,
1b1a35ee 898 misc,
136023e0 899 mmx_reg,
17df50a5 900 modifiers,
48663c56 901 module,
416331ca 902 module_path,
5099ac24 903 module_path_macro,
17df50a5 904 more_qualified_paths,
48663c56 905 more_struct_aliases,
3dfed10e 906 movbe_target_feature,
74b04a01 907 move_ref_pattern,
cdc7bbd5 908 move_size_limit,
3dfed10e
XL
909 mul,
910 mul_assign,
60c5eb7d 911 mul_with_overflow,
c295e0f8 912 must_not_suspend,
48663c56
XL
913 must_use,
914 naked,
915 naked_functions,
916 name,
5099ac24 917 names,
17df50a5
XL
918 native_link_modifiers,
919 native_link_modifiers_as_needed,
920 native_link_modifiers_bundle,
921 native_link_modifiers_verbatim,
922 native_link_modifiers_whole_archive,
3dfed10e 923 ne,
f035d41b
XL
924 nearbyintf32,
925 nearbyintf64,
48663c56 926 needs_allocator,
60c5eb7d 927 needs_drop,
48663c56 928 needs_panic_runtime,
3dfed10e 929 neg,
48663c56 930 negate_unsigned,
ba9703b0 931 negative_impls,
5099ac24 932 neon,
48663c56
XL
933 never,
934 never_type,
60c5eb7d 935 never_type_fallback,
dc9dc135 936 new,
3dfed10e 937 new_unchecked,
48663c56 938 next,
48663c56 939 nll,
3dfed10e 940 no,
48663c56
XL
941 no_builtins,
942 no_core,
cdc7bbd5 943 no_coverage,
48663c56
XL
944 no_crate_inject,
945 no_debug,
946 no_default_passes,
947 no_implicit_prelude,
948 no_inline,
949 no_link,
950 no_main,
951 no_mangle,
3dfed10e
XL
952 no_niche,
953 no_sanitize,
954 no_stack_check,
955 no_start,
956 no_std,
f9f354fc 957 nomem,
48663c56 958 non_ascii_idents,
48663c56 959 non_exhaustive,
c295e0f8 960 non_exhaustive_omitted_patterns_lint,
48663c56 961 non_modrs_mods,
3dfed10e 962 none_error,
f035d41b 963 nontemporal_store,
6a06907d
XL
964 noop_method_borrow,
965 noop_method_clone,
966 noop_method_deref,
f9f354fc 967 noreturn,
f9f354fc 968 nostack,
48663c56 969 not,
cdc7bbd5 970 notable_trait,
48663c56 971 note,
e74abb32 972 object_safe_for_dispatch,
3dfed10e 973 of,
f9f354fc 974 offset,
48663c56
XL
975 omit_gdb_pretty_printer_section,
976 on,
977 on_unimplemented,
978 oom,
3dfed10e 979 opaque,
48663c56 980 ops,
3dfed10e 981 opt_out_copy,
48663c56
XL
982 optimize,
983 optimize_attribute,
984 optin_builtin_traits,
985 option,
416331ca 986 option_env,
5099ac24 987 option_env_macro,
f9f354fc 988 options,
dc9dc135 989 or,
e1599b0c 990 or_patterns,
3dfed10e 991 other,
f9f354fc 992 out,
48663c56 993 overlapping_marker_traits,
3dfed10e 994 owned_box,
48663c56 995 packed,
dc9dc135 996 panic,
5869c6ff
XL
997 panic_2015,
998 panic_2021,
3dfed10e
XL
999 panic_abort,
1000 panic_bounds_check,
c295e0f8 1001 panic_display,
94222f64 1002 panic_fmt,
48663c56
XL
1003 panic_handler,
1004 panic_impl,
1005 panic_implementation,
3dfed10e
XL
1006 panic_info,
1007 panic_location,
5099ac24 1008 panic_no_unwind,
48663c56 1009 panic_runtime,
29967ef6 1010 panic_str,
3dfed10e 1011 panic_unwind,
fc512014 1012 panicking,
3dfed10e 1013 param_attrs,
dc9dc135 1014 partial_cmp,
3dfed10e 1015 partial_ord,
48663c56 1016 passes,
dc9dc135 1017 pat,
cdc7bbd5 1018 pat_param,
48663c56
XL
1019 path,
1020 pattern_parentheses,
3dfed10e 1021 phantom_data,
48663c56 1022 pin,
48663c56
XL
1023 platform_intrinsics,
1024 plugin,
1025 plugin_registrar,
1026 plugins,
6a06907d 1027 pointee_trait,
3dfed10e 1028 pointer,
29967ef6 1029 pointer_trait_fmt,
ba9703b0 1030 poll,
3dfed10e
XL
1031 position,
1032 post_dash_lto: "post-lto",
48663c56 1033 powerpc_target_feature,
f035d41b
XL
1034 powf32,
1035 powf64,
1036 powif32,
1037 powif64,
3dfed10e 1038 pre_dash_lto: "pre-lto",
48663c56 1039 precise_pointer_size_matching,
3dfed10e 1040 precision,
60c5eb7d 1041 pref_align_of,
f035d41b
XL
1042 prefetch_read_data,
1043 prefetch_read_instruction,
1044 prefetch_write_data,
1045 prefetch_write_instruction,
136023e0 1046 preg,
48663c56
XL
1047 prelude,
1048 prelude_import,
f9f354fc 1049 preserves_flags,
48663c56 1050 primitive,
5099ac24
FG
1051 print_macro,
1052 println_macro,
48663c56
XL
1053 proc_dash_macro: "proc-macro",
1054 proc_macro,
1055 proc_macro_attribute,
dc9dc135 1056 proc_macro_def_site,
48663c56
XL
1057 proc_macro_derive,
1058 proc_macro_expr,
1059 proc_macro_gen,
1060 proc_macro_hygiene,
416331ca 1061 proc_macro_internals,
48663c56
XL
1062 proc_macro_mod,
1063 proc_macro_non_items,
1064 proc_macro_path_invoc,
f035d41b 1065 profiler_builtins,
48663c56 1066 profiler_runtime,
5e7ed085 1067 ptr,
f035d41b
XL
1068 ptr_guaranteed_eq,
1069 ptr_guaranteed_ne,
cdc7bbd5
XL
1070 ptr_null,
1071 ptr_null_mut,
60c5eb7d 1072 ptr_offset_from,
6a06907d 1073 pub_macro_rules,
48663c56 1074 pub_restricted,
f9f354fc 1075 pure,
48663c56 1076 pushpop_unsafe,
fc512014
XL
1077 qreg,
1078 qreg_low4,
1079 qreg_low8,
48663c56
XL
1080 quad_precision_float,
1081 question_mark,
1082 quote,
3dfed10e 1083 range_inclusive_new,
e74abb32 1084 raw_dylib,
136023e0 1085 raw_eq,
48663c56 1086 raw_identifiers,
60c5eb7d 1087 raw_ref_op,
3dfed10e
XL
1088 re_rebalance_coherence,
1089 read_enum,
1090 read_enum_variant,
1091 read_enum_variant_arg,
1092 read_struct,
1093 read_struct_field,
f9f354fc 1094 readonly,
3dfed10e 1095 realloc,
48663c56 1096 reason,
3dfed10e 1097 receiver,
48663c56
XL
1098 recursion_limit,
1099 reexport_test_harness_main,
136023e0 1100 ref_unwind_safe_trait,
3dfed10e 1101 reference,
48663c56 1102 reflect,
fc512014
XL
1103 reg,
1104 reg16,
1105 reg32,
1106 reg64,
1107 reg_abcd,
1108 reg_byte,
a2a8927a 1109 reg_iw,
17df50a5 1110 reg_nonzero,
a2a8927a
XL
1111 reg_pair,
1112 reg_ptr,
1113 reg_upper,
60c5eb7d
XL
1114 register_attr,
1115 register_tool,
48663c56 1116 relaxed_adts,
5869c6ff 1117 relaxed_struct_unsize,
3dfed10e
XL
1118 rem,
1119 rem_assign,
48663c56
XL
1120 repr,
1121 repr128,
1122 repr_align,
1123 repr_align_enum,
74b04a01 1124 repr_no_niche,
48663c56
XL
1125 repr_packed,
1126 repr_simd,
1127 repr_transparent,
17df50a5 1128 residual,
48663c56 1129 result,
dc9dc135 1130 rhs,
f035d41b
XL
1131 rintf32,
1132 rintf64,
f9f354fc 1133 riscv_target_feature,
48663c56 1134 rlib,
60c5eb7d
XL
1135 rotate_left,
1136 rotate_right,
f035d41b
XL
1137 roundf32,
1138 roundf64,
dc9dc135 1139 rt,
48663c56
XL
1140 rtm_target_feature,
1141 rust,
6a06907d 1142 rust_2015,
48663c56 1143 rust_2015_preview,
6a06907d 1144 rust_2018,
48663c56 1145 rust_2018_preview,
6a06907d 1146 rust_2021,
5869c6ff 1147 rust_2021_preview,
48663c56 1148 rust_begin_unwind,
1b1a35ee 1149 rust_eh_catch_typeinfo,
3dfed10e
XL
1150 rust_eh_personality,
1151 rust_eh_register_frames,
1152 rust_eh_unregister_frames,
1153 rust_oom,
dc9dc135
XL
1154 rustc,
1155 rustc_allocator,
48663c56 1156 rustc_allocator_nounwind,
29967ef6 1157 rustc_allow_const_fn_unstable,
5e7ed085 1158 rustc_allow_incoherent_impl,
48663c56 1159 rustc_attrs,
416331ca 1160 rustc_builtin_macro,
fc512014 1161 rustc_capture_analysis,
48663c56 1162 rustc_clean,
5e7ed085 1163 rustc_coherence_is_core,
60c5eb7d 1164 rustc_const_stable,
3dfed10e 1165 rustc_const_unstable,
48663c56 1166 rustc_conversion_suggestion,
48663c56
XL
1167 rustc_def_path,
1168 rustc_deprecated,
e1599b0c 1169 rustc_diagnostic_item,
48663c56
XL
1170 rustc_diagnostic_macros,
1171 rustc_dirty,
c295e0f8 1172 rustc_do_not_const_check,
dc9dc135 1173 rustc_dummy,
48663c56
XL
1174 rustc_dump_env_program_clauses,
1175 rustc_dump_program_clauses,
1176 rustc_dump_user_substs,
94222f64 1177 rustc_dump_vtable,
48663c56 1178 rustc_error,
17df50a5 1179 rustc_evaluate_where_clauses,
48663c56
XL
1180 rustc_expected_cgu_reuse,
1181 rustc_if_this_changed,
1182 rustc_inherit_overflow_checks,
17df50a5 1183 rustc_insignificant_dtor,
48663c56
XL
1184 rustc_layout,
1185 rustc_layout_scalar_valid_range_end,
1186 rustc_layout_scalar_valid_range_start,
6a06907d 1187 rustc_legacy_const_generics,
5099ac24 1188 rustc_lint_query_instability,
416331ca 1189 rustc_macro_transparency,
cdc7bbd5 1190 rustc_main,
48663c56 1191 rustc_mir,
5099ac24 1192 rustc_must_implement_one_of,
dc9dc135 1193 rustc_nonnull_optimization_guaranteed,
48663c56
XL
1194 rustc_object_lifetime_default,
1195 rustc_on_unimplemented,
1196 rustc_outlives,
1197 rustc_paren_sugar,
1198 rustc_partition_codegened,
1199 rustc_partition_reused,
5099ac24 1200 rustc_pass_by_value,
48663c56
XL
1201 rustc_peek,
1202 rustc_peek_definite_init,
f9f354fc 1203 rustc_peek_liveness,
48663c56
XL
1204 rustc_peek_maybe_init,
1205 rustc_peek_maybe_uninit,
3dfed10e 1206 rustc_polymorphize_error,
48663c56
XL
1207 rustc_private,
1208 rustc_proc_macro_decls,
1209 rustc_promotable,
1210 rustc_regions,
3dfed10e
XL
1211 rustc_reservation_impl,
1212 rustc_serialize,
cdc7bbd5 1213 rustc_skip_array_during_method_dispatch,
ba9703b0 1214 rustc_specialization_trait,
48663c56
XL
1215 rustc_stable,
1216 rustc_std_internal_symbol,
3c0e092e 1217 rustc_strict_coherence,
48663c56 1218 rustc_symbol_name,
48663c56
XL
1219 rustc_test_marker,
1220 rustc_then_this_would_need,
c295e0f8 1221 rustc_trivial_field_reads,
3dfed10e 1222 rustc_unsafe_specialization_marker,
48663c56 1223 rustc_variance,
6a06907d 1224 rustdoc,
3c0e092e 1225 rustdoc_internals,
416331ca 1226 rustfmt,
48663c56 1227 rvalue_static_promotion,
136023e0 1228 s,
60c5eb7d 1229 sanitize,
48663c56 1230 sanitizer_runtime,
60c5eb7d
XL
1231 saturating_add,
1232 saturating_sub,
48663c56
XL
1233 self_in_typedefs,
1234 self_struct_ctor,
3dfed10e 1235 semitransparent,
3dfed10e
XL
1236 shl,
1237 shl_assign,
48663c56 1238 should_panic,
3dfed10e
XL
1239 shr,
1240 shr_assign,
48663c56 1241 simd,
3dfed10e
XL
1242 simd_add,
1243 simd_and,
5099ac24 1244 simd_as,
3dfed10e
XL
1245 simd_bitmask,
1246 simd_cast,
1247 simd_ceil,
1248 simd_div,
1249 simd_eq,
60c5eb7d 1250 simd_extract,
3dfed10e
XL
1251 simd_fabs,
1252 simd_fcos,
1253 simd_fexp,
1254 simd_fexp2,
48663c56 1255 simd_ffi,
3dfed10e
XL
1256 simd_flog,
1257 simd_flog10,
1258 simd_flog2,
1259 simd_floor,
1260 simd_fma,
1261 simd_fmax,
1262 simd_fmin,
1263 simd_fpow,
1264 simd_fpowi,
1265 simd_fsin,
1266 simd_fsqrt,
1267 simd_gather,
1268 simd_ge,
1269 simd_gt,
60c5eb7d 1270 simd_insert,
3dfed10e
XL
1271 simd_le,
1272 simd_lt,
1273 simd_mul,
1274 simd_ne,
6a06907d 1275 simd_neg,
3dfed10e
XL
1276 simd_or,
1277 simd_reduce_add_ordered,
1278 simd_reduce_add_unordered,
1279 simd_reduce_all,
1280 simd_reduce_and,
1281 simd_reduce_any,
1282 simd_reduce_max,
1283 simd_reduce_max_nanless,
1284 simd_reduce_min,
1285 simd_reduce_min_nanless,
1286 simd_reduce_mul_ordered,
1287 simd_reduce_mul_unordered,
1288 simd_reduce_or,
1289 simd_reduce_xor,
1290 simd_rem,
cdc7bbd5 1291 simd_round,
3dfed10e
XL
1292 simd_saturating_add,
1293 simd_saturating_sub,
1294 simd_scatter,
1295 simd_select,
1296 simd_select_bitmask,
1297 simd_shl,
1298 simd_shr,
c295e0f8 1299 simd_shuffle,
3dfed10e 1300 simd_sub,
cdc7bbd5 1301 simd_trunc,
3dfed10e 1302 simd_xor,
48663c56 1303 since,
f035d41b
XL
1304 sinf32,
1305 sinf64,
48663c56 1306 size,
60c5eb7d 1307 size_of,
f035d41b 1308 size_of_val,
3dfed10e 1309 sized,
6a06907d 1310 skip,
3dfed10e 1311 slice,
136023e0 1312 slice_len_fn,
48663c56
XL
1313 slice_patterns,
1314 slicing_syntax,
416331ca 1315 soft,
48663c56
XL
1316 specialization,
1317 speed,
3dfed10e 1318 spotlight,
f035d41b
XL
1319 sqrtf32,
1320 sqrtf64,
fc512014
XL
1321 sreg,
1322 sreg_low16,
5099ac24 1323 sse,
48663c56
XL
1324 sse4a_target_feature,
1325 stable,
1326 staged_api,
1327 start,
3dfed10e 1328 state,
48663c56 1329 static_in_const,
48663c56
XL
1330 static_nobundle,
1331 static_recursion,
3dfed10e 1332 staticlib,
48663c56 1333 std,
416331ca 1334 std_inject,
5869c6ff
XL
1335 std_panic,
1336 std_panic_2015_macro,
fc512014 1337 std_panic_macro,
dc9dc135 1338 stmt,
48663c56
XL
1339 stmt_expr_attributes,
1340 stop_after_dataflow,
94222f64 1341 store,
3dfed10e 1342 str,
5e7ed085
FG
1343 str_split_whitespace,
1344 str_trim,
1345 str_trim_end,
1346 str_trim_start,
3dfed10e 1347 stringify,
5099ac24 1348 stringify_macro,
48663c56
XL
1349 struct_field_attributes,
1350 struct_inherit,
48663c56 1351 struct_variant,
3dfed10e
XL
1352 structural_match,
1353 structural_peq,
1354 structural_teq,
dc9dc135 1355 sty,
3dfed10e
XL
1356 sub,
1357 sub_assign,
60c5eb7d 1358 sub_with_overflow,
48663c56 1359 suggestion,
f9f354fc 1360 sym,
3dfed10e 1361 sync,
29967ef6 1362 t32,
136023e0 1363 target_abi,
3dfed10e
XL
1364 target_arch,
1365 target_endian,
1366 target_env,
1367 target_family,
48663c56 1368 target_feature,
f9f354fc 1369 target_feature_11,
48663c56 1370 target_has_atomic,
1b1a35ee 1371 target_has_atomic_equal_alignment,
e74abb32 1372 target_has_atomic_load_store,
3dfed10e
XL
1373 target_os,
1374 target_pointer_width,
1375 target_target_vendor,
48663c56 1376 target_thread_local,
3dfed10e 1377 target_vendor,
48663c56
XL
1378 task,
1379 tbm_target_feature,
3dfed10e 1380 termination,
48663c56
XL
1381 termination_trait,
1382 termination_trait_test,
1383 test,
1384 test_2018_feature,
1385 test_accepted_feature,
dc9dc135 1386 test_case,
48663c56
XL
1387 test_removed_feature,
1388 test_runner,
5e7ed085 1389 test_unstable_lint,
dc9dc135 1390 then_with,
74b04a01 1391 thread,
48663c56 1392 thread_local,
5099ac24
FG
1393 thread_local_macro,
1394 thumb2,
1395 thumb_mode: "thumb-mode",
1396 todo_macro,
48663c56
XL
1397 tool_attributes,
1398 tool_lints,
1399 trace_macros,
e74abb32 1400 track_caller,
48663c56 1401 trait_alias,
94222f64 1402 trait_upcasting,
48663c56
XL
1403 transmute,
1404 transparent,
dc9dc135
XL
1405 transparent_enums,
1406 transparent_unions,
48663c56 1407 trivial_bounds,
f035d41b
XL
1408 truncf32,
1409 truncf64,
48663c56 1410 try_blocks,
136023e0 1411 try_from,
136023e0 1412 try_into,
17df50a5 1413 try_trait_v2,
dc9dc135 1414 tt,
3dfed10e 1415 tuple,
29967ef6 1416 tuple_from_req,
48663c56 1417 tuple_indexing,
dfeec247 1418 two_phase,
48663c56
XL
1419 ty,
1420 type_alias_enum_variants,
3dfed10e 1421 type_alias_impl_trait,
48663c56 1422 type_ascription,
3c0e092e 1423 type_changing_struct_update,
3dfed10e 1424 type_id,
48663c56
XL
1425 type_length_limit,
1426 type_macros,
3dfed10e 1427 type_name,
48663c56
XL
1428 u128,
1429 u16,
1430 u32,
1431 u64,
1432 u8,
f035d41b
XL
1433 unaligned_volatile_load,
1434 unaligned_volatile_store,
48663c56 1435 unboxed_closures,
74b04a01
XL
1436 unchecked_add,
1437 unchecked_div,
1438 unchecked_mul,
1439 unchecked_rem,
60c5eb7d
XL
1440 unchecked_shl,
1441 unchecked_shr,
74b04a01 1442 unchecked_sub,
48663c56
XL
1443 underscore_const_names,
1444 underscore_imports,
1445 underscore_lifetimes,
1446 uniform_paths,
5099ac24 1447 unimplemented_macro,
3dfed10e 1448 unit,
48663c56 1449 universal_impl_trait,
3dfed10e 1450 unix,
f035d41b 1451 unlikely,
48663c56 1452 unmarked_api,
3dfed10e 1453 unpin,
f035d41b 1454 unreachable,
a2a8927a
XL
1455 unreachable_2015,
1456 unreachable_2015_macro,
1457 unreachable_2021,
1458 unreachable_2021_macro,
48663c56 1459 unreachable_code,
a2a8927a
XL
1460 unreachable_display,
1461 unreachable_macro,
48663c56 1462 unrestricted_attribute_tokens,
f9f354fc 1463 unsafe_block_in_unsafe_fn,
3dfed10e 1464 unsafe_cell,
48663c56 1465 unsafe_no_drop_flag,
5099ac24 1466 unsafe_pin_internals,
3dfed10e 1467 unsize,
29967ef6 1468 unsized_fn_params,
48663c56
XL
1469 unsized_locals,
1470 unsized_tuple_coercion,
1471 unstable,
1472 untagged_unions,
3dfed10e 1473 unused_qualifications,
48663c56
XL
1474 unwind,
1475 unwind_attributes,
136023e0 1476 unwind_safe_trait,
29967ef6 1477 unwrap,
dc9dc135 1478 unwrap_or,
48663c56
XL
1479 use_extern_macros,
1480 use_nested_groups,
3dfed10e 1481 used,
5099ac24 1482 used_with_arg,
48663c56
XL
1483 usize,
1484 v1,
f035d41b
XL
1485 va_arg,
1486 va_copy,
1487 va_end,
3dfed10e 1488 va_list,
f035d41b 1489 va_start,
3dfed10e 1490 val,
5099ac24 1491 values,
3dfed10e
XL
1492 var,
1493 variant_count,
dc9dc135 1494 vec,
5099ac24 1495 vec_macro,
f9f354fc 1496 version,
5099ac24 1497 vfp2,
48663c56
XL
1498 vis,
1499 visible_private_types,
1500 volatile,
f035d41b
XL
1501 volatile_copy_memory,
1502 volatile_copy_nonoverlapping_memory,
1503 volatile_load,
1504 volatile_set_memory,
1505 volatile_store,
fc512014
XL
1506 vreg,
1507 vreg_low16,
48663c56 1508 warn,
cdc7bbd5 1509 wasm_abi,
48663c56
XL
1510 wasm_import_module,
1511 wasm_target_feature,
1512 while_let,
3dfed10e 1513 width,
48663c56
XL
1514 windows,
1515 windows_subsystem,
5099ac24 1516 with_negative_coherence,
60c5eb7d 1517 wrapping_add,
60c5eb7d 1518 wrapping_mul,
3dfed10e 1519 wrapping_sub,
17df50a5 1520 wreg,
f035d41b 1521 write_bytes,
5099ac24 1522 write_macro,
c295e0f8 1523 write_str,
5099ac24 1524 writeln_macro,
136023e0 1525 x87_reg,
94222f64 1526 xer,
fc512014
XL
1527 xmm_reg,
1528 ymm_reg,
1529 zmm_reg,
48663c56
XL
1530 }
1531}
1532
3dfed10e 1533#[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)]
cc61c64b
XL
1534pub struct Ident {
1535 pub name: Symbol,
83c7162d 1536 pub span: Span,
cc61c64b
XL
1537}
1538
1539impl Ident {
83c7162d 1540 #[inline]
dc9dc135 1541 /// Constructs a new identifier from a symbol and a span.
83c7162d
XL
1542 pub const fn new(name: Symbol, span: Span) -> Ident {
1543 Ident { name, span }
1544 }
0731742a 1545
e1599b0c 1546 /// Constructs a new identifier with a dummy span.
83c7162d 1547 #[inline]
e1599b0c 1548 pub const fn with_dummy_span(name: Symbol) -> Ident {
83c7162d
XL
1549 Ident::new(name, DUMMY_SP)
1550 }
1551
dc9dc135 1552 #[inline]
3c0e092e 1553 pub fn empty() -> Ident {
5869c6ff 1554 Ident::with_dummy_span(kw::Empty)
dc9dc135
XL
1555 }
1556
e1599b0c 1557 /// Maps a string to an identifier with a dummy span.
cc61c64b 1558 pub fn from_str(string: &str) -> Ident {
e1599b0c 1559 Ident::with_dummy_span(Symbol::intern(string))
cc61c64b
XL
1560 }
1561
dc9dc135
XL
1562 /// Maps a string and a span to an identifier.
1563 pub fn from_str_and_span(string: &str, span: Span) -> Ident {
1564 Ident::new(Symbol::intern(string), span)
1565 }
1566
9fa01778 1567 /// Replaces `lo` and `hi` with those from `span`, but keep hygiene context.
83c7162d
XL
1568 pub fn with_span_pos(self, span: Span) -> Ident {
1569 Ident::new(self.name, span.with_ctxt(self.span.ctxt()))
1570 }
1571
1572 pub fn without_first_quote(self) -> Ident {
0731742a 1573 Ident::new(Symbol::intern(self.as_str().trim_start_matches('\'')), self.span)
ff7c6d11
XL
1574 }
1575
8faf50e0 1576 /// "Normalize" ident for use in comparisons using "item hygiene".
ba9703b0 1577 /// Identifiers with same string value become same if they came from the same macro 2.0 macro
0731742a 1578 /// (e.g., `macro` item, but not `macro_rules` item) and stay different if they came from
ba9703b0 1579 /// different macro 2.0 macros.
8faf50e0 1580 /// Technically, this operation strips all non-opaque marks from ident's syntactic context.
ba9703b0
XL
1581 pub fn normalize_to_macros_2_0(self) -> Ident {
1582 Ident::new(self.name, self.span.normalize_to_macros_2_0())
83c7162d
XL
1583 }
1584
8faf50e0
XL
1585 /// "Normalize" ident for use in comparisons using "local variable hygiene".
1586 /// Identifiers with same string value become same if they came from the same non-transparent
0731742a 1587 /// macro (e.g., `macro` or `macro_rules!` items) and stay different if they came from different
8faf50e0
XL
1588 /// non-transparent macros.
1589 /// Technically, this operation strips all transparent marks from ident's syntactic context.
ba9703b0
XL
1590 pub fn normalize_to_macro_rules(self) -> Ident {
1591 Ident::new(self.name, self.span.normalize_to_macro_rules())
8faf50e0
XL
1592 }
1593
a2a8927a
XL
1594 /// Access the underlying string. This is a slowish operation because it
1595 /// requires locking the symbol interner.
1596 ///
1597 /// Note that the lifetime of the return value is a lie. See
1598 /// `Symbol::as_str()` for details.
1599 pub fn as_str(&self) -> &str {
94b46f34
XL
1600 self.name.as_str()
1601 }
83c7162d
XL
1602}
1603
1604impl PartialEq for Ident {
1605 fn eq(&self, rhs: &Self) -> bool {
1606 self.name == rhs.name && self.span.ctxt() == rhs.span.ctxt()
1607 }
1608}
1609
1610impl Hash for Ident {
1611 fn hash<H: Hasher>(&self, state: &mut H) {
1612 self.name.hash(state);
1613 self.span.ctxt().hash(state);
cc61c64b
XL
1614 }
1615}
1616
1617impl fmt::Debug for Ident {
9fa01778 1618 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74b04a01
XL
1619 fmt::Display::fmt(self, f)?;
1620 fmt::Debug::fmt(&self.span.ctxt(), f)
cc61c64b
XL
1621 }
1622}
1623
74b04a01
XL
1624/// This implementation is supposed to be used in error messages, so it's expected to be identical
1625/// to printing the original identifier token written in source code (`token_to_string`),
1626/// except that AST identifiers don't keep the rawness flag, so we have to guess it.
cc61c64b 1627impl fmt::Display for Ident {
9fa01778 1628 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74b04a01 1629 fmt::Display::fmt(&IdentPrinter::new(self.name, self.is_raw_guess(), None), f)
cc61c64b
XL
1630 }
1631}
1632
74b04a01
XL
1633/// This is the most general way to print identifiers.
1634/// AST pretty-printer is used as a fallback for turning AST structures into token streams for
1635/// proc macros. Additionally, proc macros may stringify their input and expect it survive the
1636/// stringification (especially true for proc macro derives written between Rust 1.15 and 1.30).
1637/// So we need to somehow pretty-print `$crate` in a way preserving at least some of its
1638/// hygiene data, most importantly name of the crate it refers to.
1639/// As a result we print `$crate` as `crate` if it refers to the local crate
1640/// and as `::other_crate_name` if it refers to some other crate.
5e7ed085 1641/// Note, that this is only done if the ident token is printed from inside of AST pretty-printing,
74b04a01
XL
1642/// but not otherwise. Pretty-printing is the only way for proc macros to discover token contents,
1643/// so we should not perform this lossy conversion if the top level call to the pretty-printer was
1644/// done for a token stream or a single token.
1645pub struct IdentPrinter {
1646 symbol: Symbol,
1647 is_raw: bool,
1648 /// Span used for retrieving the crate name to which `$crate` refers to,
1649 /// if this field is `None` then the `$crate` conversion doesn't happen.
1650 convert_dollar_crate: Option<Span>,
1651}
1652
1653impl IdentPrinter {
1654 /// The most general `IdentPrinter` constructor. Do not use this.
1655 pub fn new(symbol: Symbol, is_raw: bool, convert_dollar_crate: Option<Span>) -> IdentPrinter {
1656 IdentPrinter { symbol, is_raw, convert_dollar_crate }
1657 }
1658
1659 /// This implementation is supposed to be used when printing identifiers
1660 /// as a part of pretty-printing for larger AST pieces.
1661 /// Do not use this either.
1662 pub fn for_ast_ident(ident: Ident, is_raw: bool) -> IdentPrinter {
1663 IdentPrinter::new(ident.name, is_raw, Some(ident.span))
1664 }
1665}
1666
1667impl fmt::Display for IdentPrinter {
1668 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1669 if self.is_raw {
1670 f.write_str("r#")?;
fc512014
XL
1671 } else if self.symbol == kw::DollarCrate {
1672 if let Some(span) = self.convert_dollar_crate {
1673 let converted = span.ctxt().dollar_crate_name();
1674 if !converted.is_path_segment_keyword() {
1675 f.write_str("::")?;
74b04a01 1676 }
fc512014 1677 return fmt::Display::fmt(&converted, f);
74b04a01
XL
1678 }
1679 }
1680 fmt::Display::fmt(&self.symbol, f)
1681 }
1682}
1683
ba9703b0
XL
1684/// An newtype around `Ident` that calls [Ident::normalize_to_macro_rules] on
1685/// construction.
1686// FIXME(matthewj, petrochenkov) Use this more often, add a similar
1687// `ModernIdent` struct and use that as well.
1688#[derive(Copy, Clone, Eq, PartialEq, Hash)]
1689pub struct MacroRulesNormalizedIdent(Ident);
1690
1691impl MacroRulesNormalizedIdent {
1692 pub fn new(ident: Ident) -> Self {
1693 Self(ident.normalize_to_macro_rules())
1694 }
1695}
1696
1697impl fmt::Debug for MacroRulesNormalizedIdent {
1698 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1699 fmt::Debug::fmt(&self.0, f)
1700 }
1701}
1702
1703impl fmt::Display for MacroRulesNormalizedIdent {
1704 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1705 fmt::Display::fmt(&self.0, f)
1706 }
1707}
1708
e74abb32 1709/// An interned string.
48663c56 1710///
e74abb32 1711/// Internally, a `Symbol` is implemented as an index, and all operations
48663c56 1712/// (including hashing, equality, and ordering) operate on that index. The use
e74abb32
XL
1713/// of `rustc_index::newtype_index!` means that `Option<Symbol>` only takes up 4 bytes,
1714/// because `rustc_index::newtype_index!` reserves the last 256 values for tagging purposes.
0731742a 1715///
e74abb32 1716/// Note that `Symbol` cannot directly be a `rustc_index::newtype_index!` because it
dc9dc135 1717/// implements `fmt::Debug`, `Encodable`, and `Decodable` in special ways.
476ff2be 1718#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
0731742a
XL
1719pub struct Symbol(SymbolIndex);
1720
e74abb32 1721rustc_index::newtype_index! {
c295e0f8 1722 struct SymbolIndex { .. }
0731742a 1723}
476ff2be 1724
476ff2be 1725impl Symbol {
0731742a 1726 const fn new(n: u32) -> Self {
ba9703b0 1727 Symbol(SymbolIndex::from_u32(n))
0731742a
XL
1728 }
1729
476ff2be
SL
1730 /// Maps a string to its interned representation.
1731 pub fn intern(string: &str) -> Self {
c295e0f8 1732 with_session_globals(|session_globals| session_globals.symbol_interner.intern(string))
476ff2be
SL
1733 }
1734
a2a8927a 1735 /// Access the underlying string. This is a slowish operation because it
60c5eb7d 1736 /// requires locking the symbol interner.
a2a8927a
XL
1737 ///
1738 /// Note that the lifetime of the return value is a lie. It's not the same
1739 /// as `&self`, but actually tied to the lifetime of the underlying
1740 /// interner. Interners are long-lived, and there are very few of them, and
1741 /// this function is typically used for short-lived things, so in practice
1742 /// it works out ok.
1743 pub fn as_str(&self) -> &str {
1744 with_session_globals(|session_globals| unsafe {
1745 std::mem::transmute::<&str, &str>(session_globals.symbol_interner.get(*self))
476ff2be
SL
1746 })
1747 }
1748
83c7162d 1749 pub fn as_u32(self) -> u32 {
0731742a 1750 self.0.as_u32()
ea8adc8c 1751 }
74b04a01 1752
fc512014 1753 pub fn is_empty(self) -> bool {
5869c6ff 1754 self == kw::Empty
fc512014
XL
1755 }
1756
74b04a01
XL
1757 /// This method is supposed to be used in error messages, so it's expected to be
1758 /// identical to printing the original identifier token written in source code
1759 /// (`token_to_string`, `Ident::to_string`), except that symbols don't keep the rawness flag
1760 /// or edition, so we have to guess the rawness using the global edition.
1761 pub fn to_ident_string(self) -> String {
1762 Ident::with_dummy_span(self).to_string()
1763 }
ea8adc8c
XL
1764}
1765
476ff2be 1766impl fmt::Debug for Symbol {
9fa01778 1767 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
a2a8927a 1768 fmt::Debug::fmt(self.as_str(), f)
476ff2be
SL
1769 }
1770}
1771
1772impl fmt::Display for Symbol {
9fa01778 1773 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
a2a8927a 1774 fmt::Display::fmt(self.as_str(), f)
476ff2be
SL
1775 }
1776}
1777
3dfed10e
XL
1778impl<S: Encoder> Encodable<S> for Symbol {
1779 fn encode(&self, s: &mut S) -> Result<(), S::Error> {
a2a8927a 1780 s.emit_str(self.as_str())
476ff2be
SL
1781 }
1782}
1783
3dfed10e 1784impl<D: Decoder> Decodable<D> for Symbol {
74b04a01 1785 #[inline]
5099ac24
FG
1786 fn decode(d: &mut D) -> Symbol {
1787 Symbol::intern(&d.read_str())
476ff2be
SL
1788 }
1789}
1790
60c5eb7d
XL
1791impl<CTX> HashStable<CTX> for Symbol {
1792 #[inline]
1793 fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
1794 self.as_str().hash_stable(hcx, hasher);
1795 }
1796}
1797
1798impl<CTX> ToStableHashKey<CTX> for Symbol {
a2a8927a 1799 type KeyType = String;
60c5eb7d 1800 #[inline]
a2a8927a
XL
1801 fn to_stable_hash_key(&self, _: &CTX) -> String {
1802 self.as_str().to_string()
60c5eb7d
XL
1803 }
1804}
1805
c295e0f8
XL
1806#[derive(Default)]
1807pub(crate) struct Interner(Lock<InternerInner>);
1808
0731742a 1809// The `&'static str`s in this type actually point into the arena.
3dfed10e
XL
1810//
1811// The `FxHashMap`+`Vec` pair could be replaced by `FxIndexSet`, but #75278
1812// found that to regress performance up to 2% in some cases. This might be
1813// revisited after further improvements to `indexmap`.
c295e0f8 1814//
a2a8927a 1815// This type is private to prevent accidentally constructing more than one
5e7ed085 1816// `Interner` on the same thread, which makes it easy to mix up `Symbol`s
a2a8927a 1817// between `Interner`s.
0bf4aa26 1818#[derive(Default)]
c295e0f8 1819struct InternerInner {
94b46f34
XL
1820 arena: DroplessArena,
1821 names: FxHashMap<&'static str, Symbol>,
1822 strings: Vec<&'static str>,
476ff2be
SL
1823}
1824
1825impl Interner {
dc9dc135 1826 fn prefill(init: &[&'static str]) -> Self {
c295e0f8 1827 Interner(Lock::new(InternerInner {
dc9dc135
XL
1828 strings: init.into(),
1829 names: init.iter().copied().zip((0..).map(Symbol::new)).collect(),
1830 ..Default::default()
c295e0f8 1831 }))
476ff2be
SL
1832 }
1833
74b04a01 1834 #[inline]
c295e0f8
XL
1835 fn intern(&self, string: &str) -> Symbol {
1836 let mut inner = self.0.lock();
1837 if let Some(&name) = inner.names.get(string) {
476ff2be
SL
1838 return name;
1839 }
1840
c295e0f8 1841 let name = Symbol::new(inner.strings.len() as u32);
94b46f34 1842
a2a8927a
XL
1843 // SAFETY: we convert from `&str` to `&[u8]`, clone it into the arena,
1844 // and immediately convert the clone back to `&[u8], all because there
1845 // is no `inner.arena.alloc_str()` method. This is clearly safe.
dfeec247 1846 let string: &str =
c295e0f8 1847 unsafe { str::from_utf8_unchecked(inner.arena.alloc_slice(string.as_bytes())) };
a2a8927a
XL
1848
1849 // SAFETY: we can extend the arena allocation to `'static` because we
1850 // only access these while the arena is still alive.
dfeec247 1851 let string: &'static str = unsafe { &*(string as *const str) };
c295e0f8 1852 inner.strings.push(string);
a2a8927a
XL
1853
1854 // This second hash table lookup can be avoided by using `RawEntryMut`,
1855 // but this code path isn't hot enough for it to be worth it. See
1856 // #91445 for details.
c295e0f8 1857 inner.names.insert(string, name);
476ff2be
SL
1858 name
1859 }
60c5eb7d 1860
48663c56
XL
1861 // Get the symbol as a string. `Symbol::as_str()` should be used in
1862 // preference to this function.
c295e0f8
XL
1863 fn get(&self, symbol: Symbol) -> &str {
1864 self.0.lock().strings[symbol.0.as_usize()]
476ff2be
SL
1865 }
1866}
1867
dc9dc135 1868// This module has a very short name because it's used a lot.
ba9703b0
XL
1869/// This module contains all the defined keyword `Symbol`s.
1870///
1871/// Given that `kw` is imported, use them like `kw::keyword_name`.
1872/// For example `kw::Loop` or `kw::Break`.
dc9dc135 1873pub mod kw {
fc512014 1874 pub use super::kw_generated::*;
48663c56
XL
1875}
1876
1877// This module has a very short name because it's used a lot.
ba9703b0
XL
1878/// This module contains all the defined non-keyword `Symbol`s.
1879///
1880/// Given that `sym` is imported, use them like `sym::symbol_name`.
1881/// For example `sym::rustfmt` or `sym::u8`.
48663c56
XL
1882pub mod sym {
1883 use super::Symbol;
dfeec247 1884 use std::convert::TryInto;
dc9dc135 1885
6a06907d 1886 #[doc(inline)]
fc512014 1887 pub use super::sym_generated::*;
74b04a01
XL
1888
1889 // Used from a macro in `librustc_feature/accepted.rs`
1890 pub use super::kw::MacroRules as macro_rules;
dc9dc135 1891
fc512014
XL
1892 /// Get the symbol for an integer.
1893 ///
1894 /// The first few non-negative integers each have a static symbol and therefore
1895 /// are fast.
dc9dc135
XL
1896 pub fn integer<N: TryInto<usize> + Copy + ToString>(n: N) -> Symbol {
1897 if let Result::Ok(idx) = n.try_into() {
fc512014
XL
1898 if idx < 10 {
1899 return Symbol::new(super::SYMBOL_DIGITS_BASE + idx as u32);
dc9dc135
XL
1900 }
1901 }
1902 Symbol::intern(&n.to_string())
1903 }
94b46f34
XL
1904}
1905
1906impl Symbol {
fc512014
XL
1907 fn is_special(self) -> bool {
1908 self <= kw::Underscore
1909 }
1910
1911 fn is_used_keyword_always(self) -> bool {
1912 self >= kw::As && self <= kw::While
0731742a
XL
1913 }
1914
fc512014
XL
1915 fn is_used_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool {
1916 (self >= kw::Async && self <= kw::Dyn) && edition() >= Edition::Edition2018
dc9dc135
XL
1917 }
1918
fc512014
XL
1919 fn is_unused_keyword_always(self) -> bool {
1920 self >= kw::Abstract && self <= kw::Yield
1921 }
1922
1923 fn is_unused_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool {
1924 self == kw::Try && edition() >= Edition::Edition2018
1925 }
1926
1927 pub fn is_reserved(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
1928 self.is_special()
1929 || self.is_used_keyword_always()
1930 || self.is_unused_keyword_always()
1931 || self.is_used_keyword_conditional(edition)
1932 || self.is_unused_keyword_conditional(edition)
dc9dc135
XL
1933 }
1934
1935 /// A keyword or reserved identifier that can be used as a path segment.
1936 pub fn is_path_segment_keyword(self) -> bool {
dfeec247
XL
1937 self == kw::Super
1938 || self == kw::SelfLower
1939 || self == kw::SelfUpper
1940 || self == kw::Crate
1941 || self == kw::PathRoot
1942 || self == kw::DollarCrate
dc9dc135
XL
1943 }
1944
e1599b0c
XL
1945 /// Returns `true` if the symbol is `true` or `false`.
1946 pub fn is_bool_lit(self) -> bool {
1947 self == kw::True || self == kw::False
1948 }
1949
fc512014 1950 /// Returns `true` if this symbol can be a raw identifier.
dc9dc135 1951 pub fn can_be_raw(self) -> bool {
5869c6ff 1952 self != kw::Empty && self != kw::Underscore && !self.is_path_segment_keyword()
94b46f34
XL
1953 }
1954}
1955
1956impl Ident {
0731742a 1957 // Returns `true` for reserved identifiers used internally for elided lifetimes,
94b46f34
XL
1958 // unnamed method parameters, crate root module, error recovery etc.
1959 pub fn is_special(self) -> bool {
fc512014 1960 self.name.is_special()
94b46f34
XL
1961 }
1962
1963 /// Returns `true` if the token is a keyword used in the language.
1964 pub fn is_used_keyword(self) -> bool {
0731742a 1965 // Note: `span.edition()` is relatively expensive, don't call it unless necessary.
fc512014
XL
1966 self.name.is_used_keyword_always()
1967 || self.name.is_used_keyword_conditional(|| self.span.edition())
94b46f34
XL
1968 }
1969
1970 /// Returns `true` if the token is a keyword reserved for possible future use.
1971 pub fn is_unused_keyword(self) -> bool {
1972 // Note: `span.edition()` is relatively expensive, don't call it unless necessary.
fc512014
XL
1973 self.name.is_unused_keyword_always()
1974 || self.name.is_unused_keyword_conditional(|| self.span.edition())
94b46f34
XL
1975 }
1976
1977 /// Returns `true` if the token is either a special identifier or a keyword.
1978 pub fn is_reserved(self) -> bool {
fc512014
XL
1979 // Note: `span.edition()` is relatively expensive, don't call it unless necessary.
1980 self.name.is_reserved(|| self.span.edition())
94b46f34
XL
1981 }
1982
1983 /// A keyword or reserved identifier that can be used as a path segment.
1984 pub fn is_path_segment_keyword(self) -> bool {
dc9dc135 1985 self.name.is_path_segment_keyword()
532ac7d7
XL
1986 }
1987
1988 /// We see this identifier in a normal identifier position, like variable name or a type.
1989 /// How was it written originally? Did it use the raw form? Let's try to guess.
1990 pub fn is_raw_guess(self) -> bool {
dc9dc135 1991 self.name.can_be_raw() && self.is_reserved()
94b46f34 1992 }
476ff2be 1993}