1use std::hash::{Hash, Hasher};
6use std::ops::Deref;
7use std::{fmt, str};
8
9use rustc_arena::DroplessArena;
10use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
11use rustc_data_structures::stable_hasher::{
12 HashStable, StableCompare, StableHasher, ToStableHashKey,
13};
14use rustc_data_structures::sync::Lock;
15use rustc_macros::{Decodable, Encodable, HashStable_Generic, symbols};
16
17use crate::{DUMMY_SP, Edition, Span, with_session_globals};
18
19#[cfg(test)]
20mod tests;
21
22symbols! {
24 Keywords {
33 DollarCrate: "$crate",
39 PathRoot: "{{root}}",
40 Underscore: "_",
41 As: "as",
47 Break: "break",
48 Const: "const",
49 Continue: "continue",
50 Crate: "crate",
51 Else: "else",
52 Enum: "enum",
53 Extern: "extern",
54 False: "false",
55 Fn: "fn",
56 For: "for",
57 If: "if",
58 Impl: "impl",
59 In: "in",
60 Let: "let",
61 Loop: "loop",
62 Match: "match",
63 Mod: "mod",
64 Move: "move",
65 Mut: "mut",
66 Pub: "pub",
67 Ref: "ref",
68 Return: "return",
69 SelfLower: "self",
70 SelfUpper: "Self",
71 Static: "static",
72 Struct: "struct",
73 Super: "super",
74 Trait: "trait",
75 True: "true",
76 Type: "type",
77 Unsafe: "unsafe",
78 Use: "use",
79 Where: "where",
80 While: "while",
81 Abstract: "abstract",
87 Become: "become",
88 Box: "box",
89 Do: "do",
90 Final: "final",
91 Macro: "macro",
92 Override: "override",
93 Priv: "priv",
94 Typeof: "typeof",
95 Unsized: "unsized",
96 Virtual: "virtual",
97 Yield: "yield",
98 Async: "async", Await: "await", Dyn: "dyn", Gen: "gen", Try: "try", StaticLifetime: "'static",
121 UnderscoreLifetime: "'_",
122 Auto: "auto",
128 Builtin: "builtin",
129 Catch: "catch",
130 ContractEnsures: "contract_ensures",
131 ContractRequires: "contract_requires",
132 Default: "default",
133 MacroRules: "macro_rules",
134 Raw: "raw",
135 Reuse: "reuse",
136 Safe: "safe",
137 Union: "union",
138 Yeet: "yeet",
139 }
141
142 Symbols {
156 Abi,
158 AcqRel,
159 Acquire,
160 Any,
161 Arc,
162 ArcWeak,
163 Argument,
164 ArrayIntoIter,
165 AsMut,
166 AsRef,
167 AssertParamIsClone,
168 AssertParamIsCopy,
169 AssertParamIsEq,
170 AsyncGenFinished,
171 AsyncGenPending,
172 AsyncGenReady,
173 AtomicBool,
174 AtomicI8,
175 AtomicI16,
176 AtomicI32,
177 AtomicI64,
178 AtomicI128,
179 AtomicIsize,
180 AtomicPtr,
181 AtomicU8,
182 AtomicU16,
183 AtomicU32,
184 AtomicU64,
185 AtomicU128,
186 AtomicUsize,
187 BTreeEntry,
188 BTreeMap,
189 BTreeSet,
190 BinaryHeap,
191 Borrow,
192 BorrowMut,
193 Break,
194 BuildHasher,
195 C,
196 CStr,
197 C_dash_unwind: "C-unwind",
198 CallOnceFuture,
199 CallRefFuture,
200 Capture,
201 Cell,
202 Center,
203 Child,
204 Cleanup,
205 Clone,
206 CoercePointee,
207 CoercePointeeValidated,
208 CoerceUnsized,
209 Command,
210 ConstParamTy,
211 ConstParamTy_,
212 Context,
213 Continue,
214 ControlFlow,
215 Copy,
216 Cow,
217 Debug,
218 DebugStruct,
219 Decodable,
220 Decoder,
221 Default,
222 Deref,
223 DiagMessage,
224 Diagnostic,
225 DirBuilder,
226 DispatchFromDyn,
227 Display,
228 DoubleEndedIterator,
229 Duration,
230 Encodable,
231 Encoder,
232 Enumerate,
233 Eq,
234 Equal,
235 Err,
236 Error,
237 File,
238 FileType,
239 FmtArgumentsNew,
240 FmtWrite,
241 Fn,
242 FnMut,
243 FnOnce,
244 Formatter,
245 Forward,
246 From,
247 FromIterator,
248 FromResidual,
249 FsOpenOptions,
250 FsPermissions,
251 FusedIterator,
252 Future,
253 GlobalAlloc,
254 Hash,
255 HashMap,
256 HashMapEntry,
257 HashSet,
258 Hasher,
259 Implied,
260 InCleanup,
261 IndexOutput,
262 Input,
263 Instant,
264 Into,
265 IntoFuture,
266 IntoIterator,
267 IoBufRead,
268 IoLines,
269 IoRead,
270 IoSeek,
271 IoWrite,
272 IpAddr,
273 Ipv4Addr,
274 Ipv6Addr,
275 IrTyKind,
276 Is,
277 Item,
278 ItemContext,
279 IterEmpty,
280 IterOnce,
281 IterPeekable,
282 Iterator,
283 IteratorItem,
284 IteratorMap,
285 Layout,
286 Left,
287 LinkedList,
288 LintDiagnostic,
289 LintPass,
290 LocalKey,
291 Mutex,
292 MutexGuard,
293 N,
294 NonNull,
295 NonZero,
296 None,
297 Normal,
298 Ok,
299 Option,
300 Ord,
301 Ordering,
302 OsStr,
303 OsString,
304 Output,
305 Param,
306 ParamSet,
307 PartialEq,
308 PartialOrd,
309 Path,
310 PathBuf,
311 Pending,
312 PinCoerceUnsized,
313 PinDerefMutHelper,
314 Pointer,
315 Poll,
316 ProcMacro,
317 ProceduralMasqueradeDummyType,
318 Range,
319 RangeBounds,
320 RangeCopy,
321 RangeFrom,
322 RangeFromCopy,
323 RangeFull,
324 RangeInclusive,
325 RangeInclusiveCopy,
326 RangeMax,
327 RangeMin,
328 RangeSub,
329 RangeTo,
330 RangeToInclusive,
331 RangeToInclusiveCopy,
332 Rc,
333 RcWeak,
334 Ready,
335 Receiver,
336 RefCell,
337 RefCellRef,
338 RefCellRefMut,
339 Relaxed,
340 Release,
341 Result,
342 ResumeTy,
343 Return,
344 Reverse,
345 Right,
346 Rust,
347 RustaceansAreAwesome,
348 RwLock,
349 RwLockReadGuard,
350 RwLockWriteGuard,
351 Saturating,
352 SeekFrom,
353 SelfTy,
354 Send,
355 SeqCst,
356 Sized,
357 SliceIndex,
358 SliceIter,
359 Some,
360 SpanCtxt,
361 Stdin,
362 String,
363 StructuralPartialEq,
364 SubdiagMessage,
365 Subdiagnostic,
366 SymbolIntern,
367 Sync,
368 SyncUnsafeCell,
369 T,
370 Target,
371 This,
372 ToOwned,
373 ToString,
374 TokenStream,
375 Trait,
376 TrivialClone,
377 Try,
378 TryCaptureGeneric,
379 TryCapturePrintable,
380 TryFrom,
381 TryInto,
382 Ty,
383 TyCtxt,
384 TyKind,
385 Unknown,
386 Unsize,
387 UnsizedConstParamTy,
388 Upvars,
389 Vec,
390 VecDeque,
391 Waker,
392 Wrapper,
393 Wrapping,
394 Yield,
395 _DECLS,
396 __D,
397 __H,
398 __S,
399 __T,
400 __awaitee,
401 __try_var,
402 _t,
403 _task_context,
404 a32,
405 aarch64,
406 aarch64_target_feature,
407 aarch64_unstable_target_feature,
408 aarch64_ver_target_feature,
409 abi,
410 abi_amdgpu_kernel,
411 abi_avr_interrupt,
412 abi_c_cmse_nonsecure_call,
413 abi_cmse_nonsecure_call,
414 abi_custom,
415 abi_efiapi,
416 abi_gpu_kernel,
417 abi_msp430_interrupt,
418 abi_ptx,
419 abi_riscv_interrupt,
420 abi_sysv64,
421 abi_thiscall,
422 abi_unadjusted,
423 abi_vectorcall,
424 abi_x86_interrupt,
425 abort,
426 add,
427 add_assign,
428 add_with_overflow,
429 address,
430 adt_const_params,
431 advanced_slice_patterns,
432 adx_target_feature,
433 aes,
434 aggregate_raw_ptr,
435 alias,
436 align,
437 align_of,
438 align_of_val,
439 alignment,
440 all,
441 alloc,
442 alloc_error_handler,
443 alloc_layout,
444 alloc_zeroed,
445 allocator,
446 allocator_api,
447 allocator_internals,
448 allow,
449 allow_fail,
450 allow_internal_unsafe,
451 allow_internal_unstable,
452 altivec,
453 alu32,
454 always,
455 amdgpu,
456 analysis,
457 and,
458 and_then,
459 anon,
460 anon_adt,
461 anon_assoc,
462 anonymous_lifetime_in_impl_trait,
463 any,
464 append_const_msg,
465 apx_target_feature,
466 arbitrary_enum_discriminant,
467 arbitrary_self_types,
468 arbitrary_self_types_pointers,
469 areg,
470 args,
471 arith_offset,
472 arm,
473 arm64ec,
474 arm_target_feature,
475 array,
476 as_dash_needed: "as-needed",
477 as_ptr,
478 as_ref,
479 as_str,
480 asm,
481 asm_cfg,
482 asm_const,
483 asm_experimental_arch,
484 asm_experimental_reg,
485 asm_goto,
486 asm_goto_with_outputs,
487 asm_sym,
488 asm_unwind,
489 assert,
490 assert_eq,
491 assert_eq_macro,
492 assert_inhabited,
493 assert_macro,
494 assert_mem_uninitialized_valid,
495 assert_ne_macro,
496 assert_receiver_is_total_eq,
497 assert_zero_valid,
498 asserting,
499 associated_const_equality,
500 associated_consts,
501 associated_type_bounds,
502 associated_type_defaults,
503 associated_types,
504 assume,
505 assume_init,
506 asterisk: "*",
507 async_await,
508 async_call,
509 async_call_mut,
510 async_call_once,
511 async_closure,
512 async_drop,
513 async_drop_in_place,
514 async_fn,
515 async_fn_in_dyn_trait,
516 async_fn_in_trait,
517 async_fn_kind_helper,
518 async_fn_kind_upvars,
519 async_fn_mut,
520 async_fn_once,
521 async_fn_once_output,
522 async_fn_track_caller,
523 async_fn_traits,
524 async_for_loop,
525 async_gen_internals,
526 async_iterator,
527 async_iterator_poll_next,
528 async_trait_bounds,
529 atomic,
530 atomic_and,
531 atomic_cxchg,
532 atomic_cxchgweak,
533 atomic_fence,
534 atomic_load,
535 atomic_max,
536 atomic_min,
537 atomic_mod,
538 atomic_nand,
539 atomic_or,
540 atomic_singlethreadfence,
541 atomic_store,
542 atomic_umax,
543 atomic_umin,
544 atomic_xadd,
545 atomic_xchg,
546 atomic_xor,
547 atomic_xsub,
548 atomics,
549 att_syntax,
550 attr,
551 attr_literals,
552 attribute,
553 attributes,
554 audit_that,
555 augmented_assignments,
556 auto_cfg,
557 auto_traits,
558 autodiff,
559 autodiff_forward,
560 autodiff_reverse,
561 automatically_derived,
562 available_externally,
563 avr,
564 avx,
565 avx10_target_feature,
566 avx512_target_feature,
567 avx512bw,
568 avx512f,
569 await_macro,
570 bang,
571 begin_panic,
572 bench,
573 bevy_ecs,
574 bikeshed_guaranteed_no_drop,
575 bin,
576 binaryheap_iter,
577 bind_by_move_pattern_guards,
578 bindings_after_at,
579 bitand,
580 bitand_assign,
581 bitor,
582 bitor_assign,
583 bitreverse,
584 bitxor,
585 bitxor_assign,
586 black_box,
587 block,
588 blocking,
589 bool,
590 bool_then,
591 borrowck_graphviz_format,
592 borrowck_graphviz_postflow,
593 box_new,
594 box_patterns,
595 box_syntax,
596 boxed_slice,
597 bpf,
598 bpf_target_feature,
599 braced_empty_structs,
600 branch,
601 breakpoint,
602 bridge,
603 bswap,
604 btreemap_contains_key,
605 btreemap_insert,
606 btreeset_iter,
607 built,
608 builtin_syntax,
609 bundle,
610 c,
611 c_dash_variadic,
612 c_str,
613 c_str_literals,
614 c_unwind,
615 c_variadic,
616 c_variadic_naked_functions,
617 c_void,
618 call,
619 call_mut,
620 call_once,
621 call_once_future,
622 call_ref_future,
623 caller,
624 caller_location,
625 capture_disjoint_fields,
626 carrying_mul_add,
627 catch_unwind,
628 cause,
629 cdylib,
630 ceilf16,
631 ceilf32,
632 ceilf64,
633 ceilf128,
634 cfg,
635 cfg_accessible,
636 cfg_attr,
637 cfg_attr_multi,
638 cfg_attr_trace: "<cfg_attr_trace>", cfg_boolean_literals,
640 cfg_contract_checks,
641 cfg_doctest,
642 cfg_emscripten_wasm_eh,
643 cfg_eval,
644 cfg_fmt_debug,
645 cfg_overflow_checks,
646 cfg_panic,
647 cfg_relocation_model,
648 cfg_sanitize,
649 cfg_sanitizer_cfi,
650 cfg_select,
651 cfg_target_abi,
652 cfg_target_compact,
653 cfg_target_feature,
654 cfg_target_has_atomic,
655 cfg_target_has_atomic_equal_alignment,
656 cfg_target_has_reliable_f16_f128,
657 cfg_target_thread_local,
658 cfg_target_vendor,
659 cfg_trace: "<cfg_trace>", cfg_ub_checks,
661 cfg_version,
662 cfi,
663 cfi_encoding,
664 char,
665 char_is_ascii,
666 char_to_digit,
667 child_id,
668 child_kill,
669 client,
670 clippy,
671 clobber_abi,
672 clone,
673 clone_closures,
674 clone_fn,
675 clone_from,
676 closure,
677 closure_lifetime_binder,
678 closure_to_fn_coercion,
679 closure_track_caller,
680 cmp,
681 cmp_max,
682 cmp_min,
683 cmp_ord_max,
684 cmp_ord_min,
685 cmp_partialeq_eq,
686 cmp_partialeq_ne,
687 cmp_partialord_cmp,
688 cmp_partialord_ge,
689 cmp_partialord_gt,
690 cmp_partialord_le,
691 cmp_partialord_lt,
692 cmpxchg16b_target_feature,
693 cmse_nonsecure_entry,
694 coerce_pointee_validated,
695 coerce_shared,
696 coerce_unsized,
697 cold,
698 cold_path,
699 collapse_debuginfo,
700 column,
701 common,
702 compare_bytes,
703 compare_exchange,
704 compare_exchange_weak,
705 compile_error,
706 compiler,
707 compiler_builtins,
708 compiler_copy,
709 compiler_fence,
710 compiler_move,
711 concat,
712 concat_bytes,
713 concat_idents,
714 conservative_impl_trait,
715 console,
716 const_allocate,
717 const_async_blocks,
718 const_closures,
719 const_compare_raw_pointers,
720 const_constructor,
721 const_continue,
722 const_deallocate,
723 const_destruct,
724 const_eval_limit,
725 const_eval_select,
726 const_evaluatable_checked,
727 const_extern_fn,
728 const_fn,
729 const_fn_floating_point_arithmetic,
730 const_fn_fn_ptr_basics,
731 const_fn_trait_bound,
732 const_fn_transmute,
733 const_fn_union,
734 const_fn_unsize,
735 const_for,
736 const_format_args,
737 const_generics,
738 const_generics_defaults,
739 const_if_match,
740 const_impl_trait,
741 const_in_array_repeat_expressions,
742 const_indexing,
743 const_let,
744 const_loop,
745 const_make_global,
746 const_mut_refs,
747 const_panic,
748 const_panic_fmt,
749 const_param_ty,
750 const_precise_live_drops,
751 const_ptr_cast,
752 const_raw_ptr_deref,
753 const_raw_ptr_to_usize_cast,
754 const_refs_to_cell,
755 const_refs_to_static,
756 const_trait_bound_opt_out,
757 const_trait_impl,
758 const_try,
759 const_ty_placeholder: "<const_ty>",
760 constant,
761 constructor,
762 contract_build_check_ensures,
763 contract_check_ensures,
764 contract_check_requires,
765 contract_checks,
766 contracts,
767 contracts_ensures,
768 contracts_internals,
769 contracts_requires,
770 convert,
771 convert_identity,
772 copy,
773 copy_closures,
774 copy_nonoverlapping,
775 copysignf16,
776 copysignf32,
777 copysignf64,
778 copysignf128,
779 core,
780 core_panic,
781 core_panic_2015_macro,
782 core_panic_2021_macro,
783 core_panic_macro,
784 coroutine,
785 coroutine_clone,
786 coroutine_resume,
787 coroutine_return,
788 coroutine_state,
789 coroutine_yield,
790 coroutines,
791 cosf16,
792 cosf32,
793 cosf64,
794 cosf128,
795 count,
796 coverage,
797 coverage_attribute,
798 cr,
799 crate_in_paths,
800 crate_local,
801 crate_name,
802 crate_type,
803 crate_visibility_modifier,
804 crt_dash_static: "crt-static",
805 csky,
806 csky_target_feature,
807 cstr_type,
808 cstring_as_c_str,
809 cstring_type,
810 ctlz,
811 ctlz_nonzero,
812 ctpop,
813 ctr,
814 cttz,
815 cttz_nonzero,
816 custom_attribute,
817 custom_code_classes_in_docs,
818 custom_derive,
819 custom_inner_attributes,
820 custom_mir,
821 custom_test_frameworks,
822 d,
823 d32,
824 dbg_macro,
825 dead_code,
826 dealloc,
827 debug,
828 debug_assert_eq_macro,
829 debug_assert_macro,
830 debug_assert_ne_macro,
831 debug_assertions,
832 debug_struct,
833 debug_struct_fields_finish,
834 debug_tuple,
835 debug_tuple_fields_finish,
836 debugger_visualizer,
837 decl_macro,
838 declare_lint_pass,
839 decode,
840 decorated,
841 default_alloc_error_handler,
842 default_field_values,
843 default_fn,
844 default_lib_allocator,
845 default_method_body_is_const,
846 default_trait1,
851 default_trait2,
852 default_trait3,
853 default_trait4,
854 default_type_parameter_fallback,
856 default_type_params,
857 define_opaque,
858 delayed_bug_from_inside_query,
859 deny,
860 deprecated,
861 deprecated_safe,
862 deprecated_suggestion,
863 deref,
864 deref_method,
865 deref_mut,
866 deref_mut_method,
867 deref_patterns,
868 deref_pure,
869 deref_target,
870 derive,
871 derive_coerce_pointee,
872 derive_const,
873 derive_const_issue: "118304",
874 derive_default_enum,
875 derive_from,
876 derive_smart_pointer,
877 destruct,
878 destructuring_assignment,
879 diagnostic,
880 diagnostic_namespace,
881 diagnostic_on_const,
882 dialect,
883 direct,
884 discriminant_kind,
885 discriminant_type,
886 discriminant_value,
887 disjoint_bitor,
888 dispatch_from_dyn,
889 div,
890 div_assign,
891 diverging_block_default,
892 dl,
893 do_not_recommend,
894 doc,
895 doc_alias,
896 doc_auto_cfg,
897 doc_cfg,
898 doc_cfg_hide,
899 doc_keyword,
900 doc_masked,
901 doc_notable_trait,
902 doc_primitive,
903 doc_spotlight,
904 doctest,
905 dotdot: "..",
906 dotdot_in_tuple_patterns,
907 dotdoteq_in_patterns,
908 dreg,
909 dreg_low8,
910 dreg_low16,
911 drop,
912 drop_in_place,
913 drop_types_in_const,
914 dropck_eyepatch,
915 dropck_parametricity,
916 dummy: "<!dummy!>", dummy_cgu_name,
918 dylib,
919 dyn_compatible_for_dispatch,
920 dyn_metadata,
921 dyn_star,
922 dyn_trait,
923 dynamic_no_pic: "dynamic-no-pic",
924 e,
925 edition_panic,
926 effective_target_features,
927 effects,
928 eh_catch_typeinfo,
929 eh_personality,
930 emit,
931 emit_enum,
932 emit_enum_variant,
933 emit_enum_variant_arg,
934 emit_struct,
935 emit_struct_field,
936 empty: "",
944 emscripten_wasm_eh,
945 enable,
946 encode,
947 end,
948 entry_nops,
949 enumerate_method,
950 env,
951 env_CFG_RELEASE: env!("CFG_RELEASE"),
952 eprint_macro,
953 eprintln_macro,
954 eq,
955 ergonomic_clones,
956 ermsb_target_feature,
957 exact_div,
958 except,
959 exception_handling: "exception-handling",
960 exchange_malloc,
961 exclusive_range_pattern,
962 exhaustive_integer_patterns,
963 exhaustive_patterns,
964 existential_type,
965 exp2f16,
966 exp2f32,
967 exp2f64,
968 exp2f128,
969 expect,
970 expected,
971 expf16,
972 expf32,
973 expf64,
974 expf128,
975 explicit_extern_abis,
976 explicit_generic_args_with_impl_trait,
977 explicit_tail_calls,
978 export_name,
979 export_stable,
980 expr,
981 expr_2021,
982 expr_fragment_specifier_2024,
983 extended_key_value_attributes,
984 extended_varargs_abi_support,
985 extern_absolute_paths,
986 extern_crate_item_prelude,
987 extern_crate_self,
988 extern_in_paths,
989 extern_prelude,
990 extern_system_varargs,
991 extern_types,
992 extern_weak,
993 external,
994 external_doc,
995 f,
996 f16,
997 f16_consts_mod,
998 f16_epsilon,
999 f16_nan,
1000 f16c_target_feature,
1001 f32,
1002 f32_consts_mod,
1003 f32_epsilon,
1004 f32_legacy_const_digits,
1005 f32_legacy_const_epsilon,
1006 f32_legacy_const_infinity,
1007 f32_legacy_const_mantissa_dig,
1008 f32_legacy_const_max,
1009 f32_legacy_const_max_10_exp,
1010 f32_legacy_const_max_exp,
1011 f32_legacy_const_min,
1012 f32_legacy_const_min_10_exp,
1013 f32_legacy_const_min_exp,
1014 f32_legacy_const_min_positive,
1015 f32_legacy_const_nan,
1016 f32_legacy_const_neg_infinity,
1017 f32_legacy_const_radix,
1018 f32_nan,
1019 f64,
1020 f64_consts_mod,
1021 f64_epsilon,
1022 f64_legacy_const_digits,
1023 f64_legacy_const_epsilon,
1024 f64_legacy_const_infinity,
1025 f64_legacy_const_mantissa_dig,
1026 f64_legacy_const_max,
1027 f64_legacy_const_max_10_exp,
1028 f64_legacy_const_max_exp,
1029 f64_legacy_const_min,
1030 f64_legacy_const_min_10_exp,
1031 f64_legacy_const_min_exp,
1032 f64_legacy_const_min_positive,
1033 f64_legacy_const_nan,
1034 f64_legacy_const_neg_infinity,
1035 f64_legacy_const_radix,
1036 f64_nan,
1037 f128,
1038 f128_consts_mod,
1039 f128_epsilon,
1040 f128_nan,
1041 fabsf16,
1042 fabsf32,
1043 fabsf64,
1044 fabsf128,
1045 fadd_algebraic,
1046 fadd_fast,
1047 fake_variadic,
1048 fallback,
1049 fdiv_algebraic,
1050 fdiv_fast,
1051 feature,
1052 fence,
1053 ferris: "🦀",
1054 fetch_update,
1055 ffi,
1056 ffi_const,
1057 ffi_pure,
1058 ffi_returns_twice,
1059 field,
1060 field_init_shorthand,
1061 file,
1062 file_options,
1063 flags,
1064 float,
1065 float_to_int_unchecked,
1066 floorf16,
1067 floorf32,
1068 floorf64,
1069 floorf128,
1070 fmaf16,
1071 fmaf32,
1072 fmaf64,
1073 fmaf128,
1074 fmt,
1075 fmt_debug,
1076 fmul_algebraic,
1077 fmul_fast,
1078 fmuladdf16,
1079 fmuladdf32,
1080 fmuladdf64,
1081 fmuladdf128,
1082 fn_align,
1083 fn_body,
1084 fn_delegation,
1085 fn_must_use,
1086 fn_mut,
1087 fn_once,
1088 fn_once_output,
1089 fn_ptr_addr,
1090 fn_ptr_trait,
1091 forbid,
1092 force_target_feature,
1093 forget,
1094 format,
1095 format_args,
1096 format_args_capture,
1097 format_args_macro,
1098 format_args_nl,
1099 format_argument,
1100 format_arguments,
1101 format_macro,
1102 framework,
1103 freeze,
1104 freeze_impls,
1105 freg,
1106 frem_algebraic,
1107 frem_fast,
1108 from,
1109 from_desugaring,
1110 from_fn,
1111 from_iter,
1112 from_iter_fn,
1113 from_output,
1114 from_residual,
1115 from_size_align_unchecked,
1116 from_str,
1117 from_str_method,
1118 from_str_nonconst,
1119 from_u16,
1120 from_usize,
1121 from_yeet,
1122 frontmatter,
1123 fs_create_dir,
1124 fsub_algebraic,
1125 fsub_fast,
1126 full,
1127 fundamental,
1128 fused_iterator,
1129 future,
1130 future_drop_poll,
1131 future_output,
1132 future_trait,
1133 fxsr,
1134 gdb_script_file,
1135 ge,
1136 gen_blocks,
1137 gen_future,
1138 generator_clone,
1139 generators,
1140 generic_arg_infer,
1141 generic_assert,
1142 generic_associated_types,
1143 generic_associated_types_extended,
1144 generic_const_exprs,
1145 generic_const_items,
1146 generic_const_parameter_types,
1147 generic_param_attrs,
1148 generic_pattern_types,
1149 get_context,
1150 global_alloc_ty,
1151 global_allocator,
1152 global_asm,
1153 global_registration,
1154 globs,
1155 gt,
1156 guard_patterns,
1157 half_open_range_patterns,
1158 half_open_range_patterns_in_slices,
1159 hash,
1160 hashmap_contains_key,
1161 hashmap_drain_ty,
1162 hashmap_insert,
1163 hashmap_iter_mut_ty,
1164 hashmap_iter_ty,
1165 hashmap_keys_ty,
1166 hashmap_values_mut_ty,
1167 hashmap_values_ty,
1168 hashset_drain_ty,
1169 hashset_iter,
1170 hashset_iter_ty,
1171 hexagon,
1172 hexagon_target_feature,
1173 hidden,
1174 hide,
1175 hint,
1176 homogeneous_aggregate,
1177 host,
1178 html_favicon_url,
1179 html_logo_url,
1180 html_no_source,
1181 html_playground_url,
1182 html_root_url,
1183 hwaddress,
1184 i,
1185 i8,
1186 i8_legacy_const_max,
1187 i8_legacy_const_min,
1188 i8_legacy_fn_max_value,
1189 i8_legacy_fn_min_value,
1190 i8_legacy_mod,
1191 i16,
1192 i16_legacy_const_max,
1193 i16_legacy_const_min,
1194 i16_legacy_fn_max_value,
1195 i16_legacy_fn_min_value,
1196 i16_legacy_mod,
1197 i32,
1198 i32_legacy_const_max,
1199 i32_legacy_const_min,
1200 i32_legacy_fn_max_value,
1201 i32_legacy_fn_min_value,
1202 i32_legacy_mod,
1203 i64,
1204 i64_legacy_const_max,
1205 i64_legacy_const_min,
1206 i64_legacy_fn_max_value,
1207 i64_legacy_fn_min_value,
1208 i64_legacy_mod,
1209 i128,
1210 i128_legacy_const_max,
1211 i128_legacy_const_min,
1212 i128_legacy_fn_max_value,
1213 i128_legacy_fn_min_value,
1214 i128_legacy_mod,
1215 i128_type,
1216 ident,
1217 if_let,
1218 if_let_guard,
1219 if_let_rescope,
1220 if_while_or_patterns,
1221 ignore,
1222 immediate_abort: "immediate-abort",
1223 impl_header_lifetime_elision,
1224 impl_lint_pass,
1225 impl_trait_in_assoc_type,
1226 impl_trait_in_bindings,
1227 impl_trait_in_fn_trait_return,
1228 impl_trait_projections,
1229 implement_via_object,
1230 implied_by,
1231 import,
1232 import_name_type,
1233 import_shadowing,
1234 import_trait_associated_functions,
1235 imported_main,
1236 in_band_lifetimes,
1237 include,
1238 include_bytes,
1239 include_bytes_macro,
1240 include_str,
1241 include_str_macro,
1242 inclusive_range_syntax,
1243 index,
1244 index_mut,
1245 infer_outlives_requirements,
1246 infer_static_outlives_requirements,
1247 inherent_associated_types,
1248 inherit,
1249 initial,
1250 inlateout,
1251 inline,
1252 inline_const,
1253 inline_const_pat,
1254 inout,
1255 instant_now,
1256 instruction_set,
1257 integer_: "integer", integral,
1259 internal,
1260 internal_features,
1261 into_async_iter_into_iter,
1262 into_future,
1263 into_iter,
1264 into_try_type,
1265 intra_doc_pointers,
1266 intrinsics,
1267 intrinsics_unaligned_volatile_load,
1268 intrinsics_unaligned_volatile_store,
1269 io_error_new,
1270 io_errorkind,
1271 io_stderr,
1272 io_stdout,
1273 irrefutable_let_patterns,
1274 is,
1275 is_val_statically_known,
1276 isa_attribute,
1277 isize,
1278 isize_legacy_const_max,
1279 isize_legacy_const_min,
1280 isize_legacy_fn_max_value,
1281 isize_legacy_fn_min_value,
1282 isize_legacy_mod,
1283 issue,
1284 issue_5723_bootstrap,
1285 issue_tracker_base_url,
1286 item,
1287 item_like_imports,
1288 iter,
1289 iter_cloned,
1290 iter_copied,
1291 iter_filter,
1292 iter_mut,
1293 iter_repeat,
1294 iterator,
1295 iterator_collect_fn,
1296 kcfi,
1297 kernel_address,
1298 keylocker_x86,
1299 keyword,
1300 kind,
1301 kreg,
1302 kreg0,
1303 label,
1304 label_break_value,
1305 lahfsahf_target_feature,
1306 lang,
1307 lang_items,
1308 large_assignments,
1309 last,
1310 lateout,
1311 lazy_normalization_consts,
1312 lazy_type_alias,
1313 le,
1314 legacy_receiver,
1315 len,
1316 let_chains,
1317 let_else,
1318 lhs,
1319 lib,
1320 libc,
1321 lifetime,
1322 lifetime_capture_rules_2024,
1323 lifetimes,
1324 likely,
1325 line,
1326 link,
1327 link_arg_attribute,
1328 link_args,
1329 link_cfg,
1330 link_dash_arg: "link-arg",
1331 link_llvm_intrinsics,
1332 link_name,
1333 link_ordinal,
1334 link_section,
1335 linkage,
1336 linker,
1337 linker_messages,
1338 linkonce,
1339 linkonce_odr,
1340 lint_reasons,
1341 literal,
1342 load,
1343 loaded_from_disk,
1344 local,
1345 local_inner_macros,
1346 log2f16,
1347 log2f32,
1348 log2f64,
1349 log2f128,
1350 log10f16,
1351 log10f32,
1352 log10f64,
1353 log10f128,
1354 log_syntax,
1355 logf16,
1356 logf32,
1357 logf64,
1358 logf128,
1359 loongarch32,
1360 loongarch64,
1361 loongarch_target_feature,
1362 loop_break_value,
1363 loop_match,
1364 lr,
1365 lt,
1366 m68k,
1367 m68k_target_feature,
1368 macro_at_most_once_rep,
1369 macro_attr,
1370 macro_attributes_in_derive_output,
1371 macro_concat,
1372 macro_derive,
1373 macro_escape,
1374 macro_export,
1375 macro_lifetime_matcher,
1376 macro_literal_matcher,
1377 macro_metavar_expr,
1378 macro_metavar_expr_concat,
1379 macro_reexport,
1380 macro_use,
1381 macro_vis_matcher,
1382 macros_in_extern,
1383 main,
1384 managed_boxes,
1385 manually_drop,
1386 map,
1387 map_err,
1388 marker,
1389 marker_trait_attr,
1390 masked,
1391 match_beginning_vert,
1392 match_default_bindings,
1393 matches_macro,
1394 maximumf16,
1395 maximumf32,
1396 maximumf64,
1397 maximumf128,
1398 maxnumf16,
1399 maxnumf32,
1400 maxnumf64,
1401 maxnumf128,
1402 may_dangle,
1403 may_unwind,
1404 maybe_uninit,
1405 maybe_uninit_uninit,
1406 maybe_uninit_zeroed,
1407 mem_align_const,
1408 mem_align_of,
1409 mem_discriminant,
1410 mem_drop,
1411 mem_forget,
1412 mem_replace,
1413 mem_size_const,
1414 mem_size_of,
1415 mem_size_of_val,
1416 mem_swap,
1417 mem_uninitialized,
1418 mem_variant_count,
1419 mem_zeroed,
1420 member_constraints,
1421 memory,
1422 memtag,
1423 message,
1424 meta,
1425 meta_sized,
1426 metadata_type,
1427 min_const_fn,
1428 min_const_generics,
1429 min_const_unsafe_fn,
1430 min_exhaustive_patterns,
1431 min_generic_const_args,
1432 min_specialization,
1433 min_type_alias_impl_trait,
1434 minimumf16,
1435 minimumf32,
1436 minimumf64,
1437 minimumf128,
1438 minnumf16,
1439 minnumf32,
1440 minnumf64,
1441 minnumf128,
1442 mips,
1443 mips32r6,
1444 mips64,
1445 mips64r6,
1446 mips_target_feature,
1447 mir_assume,
1448 mir_basic_block,
1449 mir_call,
1450 mir_cast_ptr_to_ptr,
1451 mir_cast_transmute,
1452 mir_cast_unsize,
1453 mir_checked,
1454 mir_debuginfo,
1455 mir_deinit,
1456 mir_discriminant,
1457 mir_drop,
1458 mir_field,
1459 mir_goto,
1460 mir_len,
1461 mir_make_place,
1462 mir_move,
1463 mir_offset,
1464 mir_ptr_metadata,
1465 mir_retag,
1466 mir_return,
1467 mir_return_to,
1468 mir_set_discriminant,
1469 mir_static,
1470 mir_static_mut,
1471 mir_storage_dead,
1472 mir_storage_live,
1473 mir_tail_call,
1474 mir_unreachable,
1475 mir_unwind_cleanup,
1476 mir_unwind_continue,
1477 mir_unwind_resume,
1478 mir_unwind_terminate,
1479 mir_unwind_terminate_reason,
1480 mir_unwind_unreachable,
1481 mir_variant,
1482 miri,
1483 mmx_reg,
1484 modifiers,
1485 module,
1486 module_path,
1487 more_maybe_bounds,
1488 more_qualified_paths,
1489 more_struct_aliases,
1490 movbe_target_feature,
1491 move_ref_pattern,
1492 move_size_limit,
1493 movrs_target_feature,
1494 msp430,
1495 mul,
1496 mul_assign,
1497 mul_with_overflow,
1498 multiple_supertrait_upcastable,
1499 must_not_suspend,
1500 must_use,
1501 mut_preserve_binding_mode_2024,
1502 mut_ref,
1503 naked,
1504 naked_asm,
1505 naked_functions,
1506 naked_functions_rustic_abi,
1507 naked_functions_target_feature,
1508 name,
1509 names,
1510 native_link_modifiers,
1511 native_link_modifiers_as_needed,
1512 native_link_modifiers_bundle,
1513 native_link_modifiers_verbatim,
1514 native_link_modifiers_whole_archive,
1515 natvis_file,
1516 ne,
1517 needs_allocator,
1518 needs_drop,
1519 needs_panic_runtime,
1520 neg,
1521 negate_unsigned,
1522 negative_bounds,
1523 negative_impls,
1524 neon,
1525 nested,
1526 never,
1527 never_patterns,
1528 never_type,
1529 never_type_fallback,
1530 new,
1531 new_binary,
1532 new_const,
1533 new_debug,
1534 new_debug_noop,
1535 new_display,
1536 new_lower_exp,
1537 new_lower_hex,
1538 new_octal,
1539 new_pointer,
1540 new_range,
1541 new_unchecked,
1542 new_upper_exp,
1543 new_upper_hex,
1544 new_v1,
1545 new_v1_formatted,
1546 next,
1547 niko,
1548 nll,
1549 no,
1550 no_builtins,
1551 no_core,
1552 no_coverage,
1553 no_crate_inject,
1554 no_debug,
1555 no_default_passes,
1556 no_implicit_prelude,
1557 no_inline,
1558 no_link,
1559 no_main,
1560 no_mangle,
1561 no_sanitize,
1562 no_stack_check,
1563 no_std,
1564 nomem,
1565 non_ascii_idents,
1566 non_exhaustive,
1567 non_exhaustive_omitted_patterns_lint,
1568 non_lifetime_binders,
1569 non_modrs_mods,
1570 nonblocking,
1571 none,
1572 nontemporal_store,
1573 noop_method_borrow,
1574 noop_method_clone,
1575 noop_method_deref,
1576 noprefix,
1577 noreturn,
1578 nostack,
1579 not,
1580 notable_trait,
1581 note,
1582 null,
1583 nvptx64,
1584 nvptx_target_feature,
1585 object_safe_for_dispatch,
1586 of,
1587 off,
1588 offload,
1589 offset,
1590 offset_of,
1591 offset_of_enum,
1592 offset_of_nested,
1593 offset_of_slice,
1594 ok_or_else,
1595 old_name,
1596 omit_gdb_pretty_printer_section,
1597 on,
1598 on_const,
1599 on_unimplemented,
1600 opaque,
1601 opaque_module_name_placeholder: "<opaque>",
1602 open_options_new,
1603 ops,
1604 opt_out_copy,
1605 optimize,
1606 optimize_attribute,
1607 optimized,
1608 optin_builtin_traits,
1609 option,
1610 option_env,
1611 option_expect,
1612 option_unwrap,
1613 options,
1614 or,
1615 or_patterns,
1616 ord_cmp_method,
1617 os_str_to_os_string,
1618 os_string_as_os_str,
1619 other,
1620 out,
1621 overflow_checks,
1622 overlapping_marker_traits,
1623 owned_box,
1624 packed,
1625 packed_bundled_libs,
1626 panic,
1627 panic_2015,
1628 panic_2021,
1629 panic_abort,
1630 panic_any,
1631 panic_bounds_check,
1632 panic_cannot_unwind,
1633 panic_const_add_overflow,
1634 panic_const_async_fn_resumed,
1635 panic_const_async_fn_resumed_drop,
1636 panic_const_async_fn_resumed_panic,
1637 panic_const_async_gen_fn_resumed,
1638 panic_const_async_gen_fn_resumed_drop,
1639 panic_const_async_gen_fn_resumed_panic,
1640 panic_const_coroutine_resumed,
1641 panic_const_coroutine_resumed_drop,
1642 panic_const_coroutine_resumed_panic,
1643 panic_const_div_by_zero,
1644 panic_const_div_overflow,
1645 panic_const_gen_fn_none,
1646 panic_const_gen_fn_none_drop,
1647 panic_const_gen_fn_none_panic,
1648 panic_const_mul_overflow,
1649 panic_const_neg_overflow,
1650 panic_const_rem_by_zero,
1651 panic_const_rem_overflow,
1652 panic_const_shl_overflow,
1653 panic_const_shr_overflow,
1654 panic_const_sub_overflow,
1655 panic_display,
1656 panic_fmt,
1657 panic_handler,
1658 panic_impl,
1659 panic_implementation,
1660 panic_in_cleanup,
1661 panic_info,
1662 panic_invalid_enum_construction,
1663 panic_location,
1664 panic_misaligned_pointer_dereference,
1665 panic_nounwind,
1666 panic_null_pointer_dereference,
1667 panic_runtime,
1668 panic_str_2015,
1669 panic_unwind,
1670 panicking,
1671 param_attrs,
1672 parent_label,
1673 partial_cmp,
1674 partial_ord,
1675 passes,
1676 pat,
1677 pat_param,
1678 patchable_function_entry,
1679 path,
1680 path_main_separator,
1681 path_to_pathbuf,
1682 pathbuf_as_path,
1683 pattern_complexity_limit,
1684 pattern_parentheses,
1685 pattern_type,
1686 pattern_type_range_trait,
1687 pattern_types,
1688 permissions_from_mode,
1689 phantom_data,
1690 phase,
1691 pic,
1692 pie,
1693 pin,
1694 pin_ergonomics,
1695 pin_macro,
1696 pin_v2,
1697 platform_intrinsics,
1698 plugin,
1699 plugin_registrar,
1700 plugins,
1701 pointee,
1702 pointee_sized,
1703 pointee_trait,
1704 pointer,
1705 poll,
1706 poll_next,
1707 position,
1708 post_cleanup: "post-cleanup",
1709 post_dash_lto: "post-lto",
1710 postfix_match,
1711 powerpc,
1712 powerpc64,
1713 powerpc64le,
1714 powerpc_target_feature,
1715 powf16,
1716 powf32,
1717 powf64,
1718 powf128,
1719 powif16,
1720 powif32,
1721 powif64,
1722 powif128,
1723 pre_dash_lto: "pre-lto",
1724 precise_capturing,
1725 precise_capturing_in_traits,
1726 precise_pointer_size_matching,
1727 precision,
1728 pref_align_of,
1729 prefetch_read_data,
1730 prefetch_read_instruction,
1731 prefetch_write_data,
1732 prefetch_write_instruction,
1733 prefix_nops,
1734 preg,
1735 prelude,
1736 prelude_import,
1737 preserves_flags,
1738 prfchw_target_feature,
1739 print_macro,
1740 println_macro,
1741 proc_dash_macro: "proc-macro",
1742 proc_macro,
1743 proc_macro_attribute,
1744 proc_macro_derive,
1745 proc_macro_expr,
1746 proc_macro_gen,
1747 proc_macro_hygiene,
1748 proc_macro_internals,
1749 proc_macro_mod,
1750 proc_macro_non_items,
1751 proc_macro_path_invoc,
1752 process_abort,
1753 process_exit,
1754 profiler_builtins,
1755 profiler_runtime,
1756 ptr,
1757 ptr_cast,
1758 ptr_cast_const,
1759 ptr_cast_mut,
1760 ptr_const_is_null,
1761 ptr_copy,
1762 ptr_copy_nonoverlapping,
1763 ptr_eq,
1764 ptr_from_ref,
1765 ptr_guaranteed_cmp,
1766 ptr_is_null,
1767 ptr_mask,
1768 ptr_metadata,
1769 ptr_null,
1770 ptr_null_mut,
1771 ptr_offset_from,
1772 ptr_offset_from_unsigned,
1773 ptr_read,
1774 ptr_read_unaligned,
1775 ptr_read_volatile,
1776 ptr_replace,
1777 ptr_slice_from_raw_parts,
1778 ptr_slice_from_raw_parts_mut,
1779 ptr_swap,
1780 ptr_swap_nonoverlapping,
1781 ptr_write,
1782 ptr_write_bytes,
1783 ptr_write_unaligned,
1784 ptr_write_volatile,
1785 pub_macro_rules,
1786 pub_restricted,
1787 public,
1788 pure,
1789 pushpop_unsafe,
1790 qreg,
1791 qreg_low4,
1792 qreg_low8,
1793 quad_precision_float,
1794 question_mark,
1795 quote,
1796 range_inclusive_new,
1797 range_step,
1798 raw_dash_dylib: "raw-dylib",
1799 raw_dylib,
1800 raw_dylib_elf,
1801 raw_eq,
1802 raw_identifiers,
1803 raw_ref_op,
1804 re_rebalance_coherence,
1805 read_enum,
1806 read_enum_variant,
1807 read_enum_variant_arg,
1808 read_struct,
1809 read_struct_field,
1810 read_via_copy,
1811 readonly,
1812 realloc,
1813 realtime,
1814 reason,
1815 reborrow,
1816 receiver,
1817 receiver_target,
1818 recursion_limit,
1819 reexport_test_harness_main,
1820 ref_pat_eat_one_layer_2024,
1821 ref_pat_eat_one_layer_2024_structural,
1822 ref_pat_everywhere,
1823 ref_unwind_safe_trait,
1824 reference,
1825 reflect,
1826 reg,
1827 reg16,
1828 reg32,
1829 reg64,
1830 reg_abcd,
1831 reg_addr,
1832 reg_byte,
1833 reg_data,
1834 reg_iw,
1835 reg_nonzero,
1836 reg_pair,
1837 reg_ptr,
1838 reg_upper,
1839 register_attr,
1840 register_tool,
1841 relaxed_adts,
1842 relaxed_struct_unsize,
1843 relocation_model,
1844 rem,
1845 rem_assign,
1846 repr,
1847 repr128,
1848 repr_align,
1849 repr_align_enum,
1850 repr_packed,
1851 repr_simd,
1852 repr_transparent,
1853 require,
1854 reserve_x18: "reserve-x18",
1855 residual,
1856 result,
1857 result_ffi_guarantees,
1858 result_ok_method,
1859 resume,
1860 return_position_impl_trait_in_trait,
1861 return_type_notation,
1862 riscv32,
1863 riscv64,
1864 riscv_target_feature,
1865 rlib,
1866 ropi,
1867 ropi_rwpi: "ropi-rwpi",
1868 rotate_left,
1869 rotate_right,
1870 round_ties_even_f16,
1871 round_ties_even_f32,
1872 round_ties_even_f64,
1873 round_ties_even_f128,
1874 roundf16,
1875 roundf32,
1876 roundf64,
1877 roundf128,
1878 rt,
1879 rtm_target_feature,
1880 runtime,
1881 rust,
1882 rust_2015,
1883 rust_2018,
1884 rust_2018_preview,
1885 rust_2021,
1886 rust_2024,
1887 rust_analyzer,
1888 rust_begin_unwind,
1889 rust_cold_cc,
1890 rust_eh_catch_typeinfo,
1891 rust_eh_personality,
1892 rust_future,
1893 rust_logo,
1894 rust_out,
1895 rustc,
1896 rustc_abi,
1897 rustc_align,
1899 rustc_align_static,
1900 rustc_allocator,
1901 rustc_allocator_zeroed,
1902 rustc_allocator_zeroed_variant,
1903 rustc_allow_const_fn_unstable,
1904 rustc_allow_incoherent_impl,
1905 rustc_allowed_through_unstable_modules,
1906 rustc_as_ptr,
1907 rustc_attrs,
1908 rustc_autodiff,
1909 rustc_builtin_macro,
1910 rustc_capture_analysis,
1911 rustc_clean,
1912 rustc_coherence_is_core,
1913 rustc_coinductive,
1914 rustc_confusables,
1915 rustc_const_stable,
1916 rustc_const_stable_indirect,
1917 rustc_const_unstable,
1918 rustc_conversion_suggestion,
1919 rustc_deallocator,
1920 rustc_def_path,
1921 rustc_default_body_unstable,
1922 rustc_delayed_bug_from_inside_query,
1923 rustc_deny_explicit_impl,
1924 rustc_deprecated_safe_2024,
1925 rustc_diagnostic_item,
1926 rustc_diagnostic_macros,
1927 rustc_dirty,
1928 rustc_do_not_const_check,
1929 rustc_do_not_implement_via_object,
1930 rustc_doc_primitive,
1931 rustc_driver,
1932 rustc_dummy,
1933 rustc_dump_def_parents,
1934 rustc_dump_item_bounds,
1935 rustc_dump_predicates,
1936 rustc_dump_user_args,
1937 rustc_dump_vtable,
1938 rustc_effective_visibility,
1939 rustc_evaluate_where_clauses,
1940 rustc_expected_cgu_reuse,
1941 rustc_force_inline,
1942 rustc_has_incoherent_inherent_impls,
1943 rustc_hidden_type_of_opaques,
1944 rustc_if_this_changed,
1945 rustc_inherit_overflow_checks,
1946 rustc_insignificant_dtor,
1947 rustc_intrinsic,
1948 rustc_intrinsic_const_stable_indirect,
1949 rustc_layout,
1950 rustc_layout_scalar_valid_range_end,
1951 rustc_layout_scalar_valid_range_start,
1952 rustc_legacy_const_generics,
1953 rustc_lint_diagnostics,
1954 rustc_lint_opt_deny_field_access,
1955 rustc_lint_opt_ty,
1956 rustc_lint_query_instability,
1957 rustc_lint_untracked_query_information,
1958 rustc_macro_transparency,
1959 rustc_main,
1960 rustc_mir,
1961 rustc_must_implement_one_of,
1962 rustc_never_returns_null_ptr,
1963 rustc_never_type_options,
1964 rustc_no_implicit_autorefs,
1965 rustc_no_implicit_bounds,
1966 rustc_no_mir_inline,
1967 rustc_nonnull_optimization_guaranteed,
1968 rustc_nounwind,
1969 rustc_objc_class,
1970 rustc_objc_selector,
1971 rustc_object_lifetime_default,
1972 rustc_offload_kernel,
1973 rustc_on_unimplemented,
1974 rustc_outlives,
1975 rustc_paren_sugar,
1976 rustc_partition_codegened,
1977 rustc_partition_reused,
1978 rustc_pass_by_value,
1979 rustc_pass_indirectly_in_non_rustic_abis,
1980 rustc_peek,
1981 rustc_peek_liveness,
1982 rustc_peek_maybe_init,
1983 rustc_peek_maybe_uninit,
1984 rustc_preserve_ub_checks,
1985 rustc_private,
1986 rustc_proc_macro_decls,
1987 rustc_promotable,
1988 rustc_pub_transparent,
1989 rustc_reallocator,
1990 rustc_regions,
1991 rustc_reservation_impl,
1992 rustc_serialize,
1993 rustc_should_not_be_called_on_const_items,
1994 rustc_simd_monomorphize_lane_limit,
1995 rustc_skip_during_method_dispatch,
1996 rustc_specialization_trait,
1997 rustc_std_internal_symbol,
1998 rustc_strict_coherence,
1999 rustc_symbol_name,
2000 rustc_test_marker,
2001 rustc_then_this_would_need,
2002 rustc_trivial_field_reads,
2003 rustc_unsafe_specialization_marker,
2004 rustc_variance,
2005 rustc_variance_of_opaques,
2006 rustdoc,
2007 rustdoc_internals,
2008 rustdoc_missing_doc_code_examples,
2009 rustfmt,
2010 rvalue_static_promotion,
2011 rwpi,
2012 s,
2013 s390x,
2014 s390x_target_feature,
2015 s390x_target_feature_vector,
2016 safety,
2017 sanitize,
2018 sanitizer_cfi_generalize_pointers,
2019 sanitizer_cfi_normalize_integers,
2020 sanitizer_runtime,
2021 saturating_add,
2022 saturating_div,
2023 saturating_sub,
2024 sdylib,
2025 search_unbox,
2026 select_unpredictable,
2027 self_in_typedefs,
2028 self_struct_ctor,
2029 semiopaque,
2030 semitransparent,
2031 sha2,
2032 sha3,
2033 sha512_sm_x86,
2034 shadow_call_stack,
2035 shallow,
2036 shl,
2037 shl_assign,
2038 shorter_tail_lifetimes,
2039 should_panic,
2040 show,
2041 shr,
2042 shr_assign,
2043 sig_dfl,
2044 sig_ign,
2045 simd,
2046 simd_add,
2047 simd_and,
2048 simd_arith_offset,
2049 simd_as,
2050 simd_bitmask,
2051 simd_bitreverse,
2052 simd_bswap,
2053 simd_cast,
2054 simd_cast_ptr,
2055 simd_ceil,
2056 simd_ctlz,
2057 simd_ctpop,
2058 simd_cttz,
2059 simd_div,
2060 simd_eq,
2061 simd_expose_provenance,
2062 simd_extract,
2063 simd_extract_dyn,
2064 simd_fabs,
2065 simd_fcos,
2066 simd_fexp,
2067 simd_fexp2,
2068 simd_ffi,
2069 simd_flog,
2070 simd_flog2,
2071 simd_flog10,
2072 simd_floor,
2073 simd_fma,
2074 simd_fmax,
2075 simd_fmin,
2076 simd_fsin,
2077 simd_fsqrt,
2078 simd_funnel_shl,
2079 simd_funnel_shr,
2080 simd_gather,
2081 simd_ge,
2082 simd_gt,
2083 simd_insert,
2084 simd_insert_dyn,
2085 simd_le,
2086 simd_lt,
2087 simd_masked_load,
2088 simd_masked_store,
2089 simd_mul,
2090 simd_ne,
2091 simd_neg,
2092 simd_or,
2093 simd_reduce_add_ordered,
2094 simd_reduce_add_unordered,
2095 simd_reduce_all,
2096 simd_reduce_and,
2097 simd_reduce_any,
2098 simd_reduce_max,
2099 simd_reduce_min,
2100 simd_reduce_mul_ordered,
2101 simd_reduce_mul_unordered,
2102 simd_reduce_or,
2103 simd_reduce_xor,
2104 simd_relaxed_fma,
2105 simd_rem,
2106 simd_round,
2107 simd_round_ties_even,
2108 simd_saturating_add,
2109 simd_saturating_sub,
2110 simd_scatter,
2111 simd_select,
2112 simd_select_bitmask,
2113 simd_shl,
2114 simd_shr,
2115 simd_shuffle,
2116 simd_shuffle_const_generic,
2117 simd_sub,
2118 simd_trunc,
2119 simd_with_exposed_provenance,
2120 simd_xor,
2121 since,
2122 sinf16,
2123 sinf32,
2124 sinf64,
2125 sinf128,
2126 size,
2127 size_of,
2128 size_of_val,
2129 sized,
2130 sized_hierarchy,
2131 skip,
2132 slice,
2133 slice_from_raw_parts,
2134 slice_from_raw_parts_mut,
2135 slice_from_ref,
2136 slice_get_unchecked,
2137 slice_into_vec,
2138 slice_iter,
2139 slice_len_fn,
2140 slice_patterns,
2141 slicing_syntax,
2142 soft,
2143 sparc,
2144 sparc64,
2145 sparc_target_feature,
2146 spe_acc,
2147 specialization,
2148 speed,
2149 spirv,
2150 spotlight,
2151 sqrtf16,
2152 sqrtf32,
2153 sqrtf64,
2154 sqrtf128,
2155 sreg,
2156 sreg_low16,
2157 sse,
2158 sse2,
2159 sse4a_target_feature,
2160 stable,
2161 staged_api,
2162 start,
2163 state,
2164 static_align,
2165 static_in_const,
2166 static_nobundle,
2167 static_recursion,
2168 staticlib,
2169 std,
2170 std_lib_injection,
2171 std_panic,
2172 std_panic_2015_macro,
2173 std_panic_macro,
2174 stmt,
2175 stmt_expr_attributes,
2176 stop_after_dataflow,
2177 store,
2178 str,
2179 str_chars,
2180 str_ends_with,
2181 str_from_utf8,
2182 str_from_utf8_mut,
2183 str_from_utf8_unchecked,
2184 str_from_utf8_unchecked_mut,
2185 str_inherent_from_utf8,
2186 str_inherent_from_utf8_mut,
2187 str_inherent_from_utf8_unchecked,
2188 str_inherent_from_utf8_unchecked_mut,
2189 str_len,
2190 str_split_whitespace,
2191 str_starts_with,
2192 str_trim,
2193 str_trim_end,
2194 str_trim_start,
2195 strict_provenance_lints,
2196 string_as_mut_str,
2197 string_as_str,
2198 string_deref_patterns,
2199 string_from_utf8,
2200 string_insert_str,
2201 string_new,
2202 string_push_str,
2203 stringify,
2204 struct_field_attributes,
2205 struct_inherit,
2206 struct_variant,
2207 structural_match,
2208 structural_peq,
2209 sub,
2210 sub_assign,
2211 sub_with_overflow,
2212 suggestion,
2213 super_let,
2214 supertrait_item_shadowing,
2215 sym,
2216 sync,
2217 synthetic,
2218 sys_mutex_lock,
2219 sys_mutex_try_lock,
2220 sys_mutex_unlock,
2221 t32,
2222 target,
2223 target_abi,
2224 target_arch,
2225 target_endian,
2226 target_env,
2227 target_family,
2228 target_feature,
2229 target_feature_11,
2230 target_feature_inline_always,
2231 target_has_atomic,
2232 target_has_atomic_equal_alignment,
2233 target_has_atomic_load_store,
2234 target_has_reliable_f16,
2235 target_has_reliable_f16_math,
2236 target_has_reliable_f128,
2237 target_has_reliable_f128_math,
2238 target_os,
2239 target_pointer_width,
2240 target_thread_local,
2241 target_vendor,
2242 tbm_target_feature,
2243 termination,
2244 termination_trait,
2245 termination_trait_test,
2246 test,
2247 test_2018_feature,
2248 test_accepted_feature,
2249 test_case,
2250 test_removed_feature,
2251 test_runner,
2252 test_unstable_lint,
2253 thread,
2254 thread_local,
2255 thread_local_macro,
2256 three_way_compare,
2257 thumb2,
2258 thumb_mode: "thumb-mode",
2259 tmm_reg,
2260 to_owned_method,
2261 to_string,
2262 to_string_method,
2263 to_vec,
2264 todo_macro,
2265 tool_attributes,
2266 tool_lints,
2267 trace_macros,
2268 track_caller,
2269 trait_alias,
2270 trait_upcasting,
2271 transmute,
2272 transmute_generic_consts,
2273 transmute_opts,
2274 transmute_trait,
2275 transmute_unchecked,
2276 transparent,
2277 transparent_enums,
2278 transparent_unions,
2279 trivial_bounds,
2280 trivial_clone,
2281 truncf16,
2282 truncf32,
2283 truncf64,
2284 truncf128,
2285 try_blocks,
2286 try_capture,
2287 try_from,
2288 try_from_fn,
2289 try_into,
2290 try_trait_v2,
2291 try_trait_v2_residual,
2292 try_update,
2293 tt,
2294 tuple,
2295 tuple_indexing,
2296 tuple_trait,
2297 two_phase,
2298 ty,
2299 type_alias_enum_variants,
2300 type_alias_impl_trait,
2301 type_ascribe,
2302 type_ascription,
2303 type_changing_struct_update,
2304 type_const,
2305 type_id,
2306 type_id_eq,
2307 type_ir,
2308 type_ir_infer_ctxt_like,
2309 type_ir_inherent,
2310 type_ir_interner,
2311 type_length_limit,
2312 type_macros,
2313 type_name,
2314 type_privacy_lints,
2315 typed_swap_nonoverlapping,
2316 u8,
2317 u8_legacy_const_max,
2318 u8_legacy_const_min,
2319 u8_legacy_fn_max_value,
2320 u8_legacy_fn_min_value,
2321 u8_legacy_mod,
2322 u16,
2323 u16_legacy_const_max,
2324 u16_legacy_const_min,
2325 u16_legacy_fn_max_value,
2326 u16_legacy_fn_min_value,
2327 u16_legacy_mod,
2328 u32,
2329 u32_legacy_const_max,
2330 u32_legacy_const_min,
2331 u32_legacy_fn_max_value,
2332 u32_legacy_fn_min_value,
2333 u32_legacy_mod,
2334 u64,
2335 u64_legacy_const_max,
2336 u64_legacy_const_min,
2337 u64_legacy_fn_max_value,
2338 u64_legacy_fn_min_value,
2339 u64_legacy_mod,
2340 u128,
2341 u128_legacy_const_max,
2342 u128_legacy_const_min,
2343 u128_legacy_fn_max_value,
2344 u128_legacy_fn_min_value,
2345 u128_legacy_mod,
2346 ub_checks,
2347 unaligned_volatile_load,
2348 unaligned_volatile_store,
2349 unboxed_closures,
2350 unchecked_add,
2351 unchecked_div,
2352 unchecked_funnel_shl,
2353 unchecked_funnel_shr,
2354 unchecked_mul,
2355 unchecked_rem,
2356 unchecked_shl,
2357 unchecked_shr,
2358 unchecked_sub,
2359 undecorated,
2360 underscore_const_names,
2361 underscore_imports,
2362 underscore_lifetimes,
2363 uniform_paths,
2364 unimplemented_macro,
2365 unit,
2366 universal_impl_trait,
2367 unix,
2368 unlikely,
2369 unmarked_api,
2370 unnamed_fields,
2371 unpin,
2372 unqualified_local_imports,
2373 unreachable,
2374 unreachable_2015,
2375 unreachable_2015_macro,
2376 unreachable_2021,
2377 unreachable_code,
2378 unreachable_display,
2379 unreachable_macro,
2380 unrestricted_attribute_tokens,
2381 unsafe_attributes,
2382 unsafe_binders,
2383 unsafe_block_in_unsafe_fn,
2384 unsafe_cell,
2385 unsafe_cell_raw_get,
2386 unsafe_extern_blocks,
2387 unsafe_fields,
2388 unsafe_no_drop_flag,
2389 unsafe_pinned,
2390 unsafe_unpin,
2391 unsize,
2392 unsized_const_param_ty,
2393 unsized_const_params,
2394 unsized_fn_params,
2395 unsized_locals,
2396 unsized_tuple_coercion,
2397 unstable,
2398 unstable_feature_bound,
2399 unstable_location_reason_default: "this crate is being loaded from the sysroot, an \
2400 unstable location; did you mean to load this crate \
2401 from crates.io via `Cargo.toml` instead?",
2402 untagged_unions,
2403 unused_imports,
2404 unwind,
2405 unwind_attributes,
2406 unwind_safe_trait,
2407 unwrap,
2408 unwrap_binder,
2409 unwrap_or,
2410 update,
2411 use_cloned,
2412 use_extern_macros,
2413 use_nested_groups,
2414 used,
2415 used_with_arg,
2416 using,
2417 usize,
2418 usize_legacy_const_max,
2419 usize_legacy_const_min,
2420 usize_legacy_fn_max_value,
2421 usize_legacy_fn_min_value,
2422 usize_legacy_mod,
2423 v1,
2424 v8plus,
2425 va_arg,
2426 va_copy,
2427 va_end,
2428 va_list,
2429 va_start,
2430 val,
2431 validity,
2432 value,
2433 values,
2434 var,
2435 variant_count,
2436 vec,
2437 vec_as_mut_slice,
2438 vec_as_slice,
2439 vec_from_elem,
2440 vec_is_empty,
2441 vec_macro,
2442 vec_new,
2443 vec_pop,
2444 vec_reserve,
2445 vec_with_capacity,
2446 vecdeque_iter,
2447 vecdeque_reserve,
2448 vector,
2449 verbatim,
2450 version,
2451 vfp2,
2452 vis,
2453 visible_private_types,
2454 volatile,
2455 volatile_copy_memory,
2456 volatile_copy_nonoverlapping_memory,
2457 volatile_load,
2458 volatile_set_memory,
2459 volatile_store,
2460 vreg,
2461 vreg_low16,
2462 vsreg,
2463 vsx,
2464 vtable_align,
2465 vtable_size,
2466 warn,
2467 wasip2,
2468 wasm32,
2469 wasm64,
2470 wasm_abi,
2471 wasm_import_module,
2472 wasm_target_feature,
2473 weak,
2474 weak_odr,
2475 where_clause_attrs,
2476 while_let,
2477 whole_dash_archive: "whole-archive",
2478 width,
2479 windows,
2480 windows_subsystem,
2481 with_negative_coherence,
2482 wrap_binder,
2483 wrapping_add,
2484 wrapping_div,
2485 wrapping_mul,
2486 wrapping_rem,
2487 wrapping_rem_euclid,
2488 wrapping_sub,
2489 wreg,
2490 write_bytes,
2491 write_fmt,
2492 write_macro,
2493 write_str,
2494 write_via_move,
2495 writeln_macro,
2496 x86,
2497 x86_64,
2498 x86_amx_intrinsics,
2499 x87_reg,
2500 x87_target_feature,
2501 xer,
2502 xmm_reg,
2503 xop_target_feature,
2504 xtensa,
2505 yeet_desugar_details,
2506 yeet_expr,
2507 yes,
2508 yield_expr,
2509 ymm_reg,
2510 yreg,
2511 zca,
2512 zfh,
2513 zfhmin,
2514 zmm_reg,
2515 ztso,
2516 }
2518}
2519
2520pub const STDLIB_STABLE_CRATES: &[Symbol] = &[sym::std, sym::core, sym::alloc, sym::proc_macro];
2523
2524#[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)]
2525pub struct Ident {
2526 pub name: Symbol,
2531 pub span: Span,
2532}
2533
2534impl Ident {
2535 #[inline]
2536 pub fn new(name: Symbol, span: Span) -> Ident {
2538 debug_assert_ne!(name, sym::empty);
2539 Ident { name, span }
2540 }
2541
2542 #[inline]
2544 pub fn with_dummy_span(name: Symbol) -> Ident {
2545 Ident::new(name, DUMMY_SP)
2546 }
2547
2548 #[inline]
2553 pub fn dummy() -> Ident {
2554 Ident::with_dummy_span(sym::dummy)
2555 }
2556
2557 pub fn from_str(string: &str) -> Ident {
2559 Ident::with_dummy_span(Symbol::intern(string))
2560 }
2561
2562 pub fn from_str_and_span(string: &str, span: Span) -> Ident {
2564 Ident::new(Symbol::intern(string), span)
2565 }
2566
2567 pub fn with_span_pos(self, span: Span) -> Ident {
2569 Ident::new(self.name, span.with_ctxt(self.span.ctxt()))
2570 }
2571
2572 pub fn without_first_quote(self) -> Ident {
2575 self.as_str()
2576 .strip_prefix('\'')
2577 .map_or(self, |name| Ident::new(Symbol::intern(name), self.span))
2578 }
2579
2580 pub fn normalize_to_macros_2_0(self) -> Ident {
2586 Ident::new(self.name, self.span.normalize_to_macros_2_0())
2587 }
2588
2589 #[inline]
2595 pub fn normalize_to_macro_rules(self) -> Ident {
2596 Ident::new(self.name, self.span.normalize_to_macro_rules())
2597 }
2598
2599 pub fn as_str(&self) -> &str {
2605 self.name.as_str()
2606 }
2607}
2608
2609impl PartialEq for Ident {
2610 #[inline]
2611 fn eq(&self, rhs: &Self) -> bool {
2612 self.name == rhs.name && self.span.eq_ctxt(rhs.span)
2613 }
2614}
2615
2616impl Hash for Ident {
2617 fn hash<H: Hasher>(&self, state: &mut H) {
2618 self.name.hash(state);
2619 self.span.ctxt().hash(state);
2620 }
2621}
2622
2623impl fmt::Debug for Ident {
2624 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2625 fmt::Display::fmt(self, f)?;
2626 fmt::Debug::fmt(&self.span.ctxt(), f)
2627 }
2628}
2629
2630impl fmt::Display for Ident {
2634 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2635 fmt::Display::fmt(&IdentPrinter::new(self.name, self.guess_print_mode(), None), f)
2636 }
2637}
2638
2639pub enum IdentPrintMode {
2640 Normal,
2641 RawIdent,
2642 RawLifetime,
2643}
2644
2645pub struct IdentPrinter {
2659 symbol: Symbol,
2660 mode: IdentPrintMode,
2661 convert_dollar_crate: Option<Span>,
2664}
2665
2666impl IdentPrinter {
2667 pub fn new(
2669 symbol: Symbol,
2670 mode: IdentPrintMode,
2671 convert_dollar_crate: Option<Span>,
2672 ) -> IdentPrinter {
2673 IdentPrinter { symbol, mode, convert_dollar_crate }
2674 }
2675
2676 pub fn for_ast_ident(ident: Ident, mode: IdentPrintMode) -> IdentPrinter {
2680 IdentPrinter::new(ident.name, mode, Some(ident.span))
2681 }
2682}
2683
2684impl fmt::Display for IdentPrinter {
2685 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2686 let s = match self.mode {
2687 IdentPrintMode::Normal
2688 if self.symbol == kw::DollarCrate
2689 && let Some(span) = self.convert_dollar_crate =>
2690 {
2691 let converted = span.ctxt().dollar_crate_name();
2692 if !converted.is_path_segment_keyword() {
2693 f.write_str("::")?;
2694 }
2695 converted
2696 }
2697 IdentPrintMode::Normal => self.symbol,
2698 IdentPrintMode::RawIdent => {
2699 f.write_str("r#")?;
2700 self.symbol
2701 }
2702 IdentPrintMode::RawLifetime => {
2703 f.write_str("'r#")?;
2704 let s = self
2705 .symbol
2706 .as_str()
2707 .strip_prefix("'")
2708 .expect("only lifetime idents should be passed with RawLifetime mode");
2709 Symbol::intern(s)
2710 }
2711 };
2712 s.fmt(f)
2713 }
2714}
2715
2716#[derive(Copy, Clone, Eq, PartialEq, Hash)]
2722pub struct MacroRulesNormalizedIdent(Ident);
2723
2724impl MacroRulesNormalizedIdent {
2725 #[inline]
2726 pub fn new(ident: Ident) -> Self {
2727 MacroRulesNormalizedIdent(ident.normalize_to_macro_rules())
2728 }
2729}
2730
2731impl fmt::Debug for MacroRulesNormalizedIdent {
2732 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2733 fmt::Debug::fmt(&self.0, f)
2734 }
2735}
2736
2737impl fmt::Display for MacroRulesNormalizedIdent {
2738 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2739 fmt::Display::fmt(&self.0, f)
2740 }
2741}
2742
2743#[derive(Copy, Clone, Eq, PartialEq, Hash)]
2750pub struct Macros20NormalizedIdent(pub Ident);
2751
2752impl Macros20NormalizedIdent {
2753 #[inline]
2754 pub fn new(ident: Ident) -> Self {
2755 Macros20NormalizedIdent(ident.normalize_to_macros_2_0())
2756 }
2757
2758 pub fn with_dummy_span(name: Symbol) -> Self {
2760 Macros20NormalizedIdent(Ident::with_dummy_span(name))
2761 }
2762}
2763
2764impl fmt::Debug for Macros20NormalizedIdent {
2765 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2766 fmt::Debug::fmt(&self.0, f)
2767 }
2768}
2769
2770impl fmt::Display for Macros20NormalizedIdent {
2771 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2772 fmt::Display::fmt(&self.0, f)
2773 }
2774}
2775
2776impl Deref for Macros20NormalizedIdent {
2779 type Target = Ident;
2780 fn deref(&self) -> &Self::Target {
2781 &self.0
2782 }
2783}
2784
2785#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2795pub struct Symbol(SymbolIndex);
2796
2797rustc_index::newtype_index! {
2799 #[orderable]
2800 struct SymbolIndex {}
2801}
2802
2803impl Symbol {
2804 pub const fn new(n: u32) -> Self {
2807 Symbol(SymbolIndex::from_u32(n))
2808 }
2809
2810 #[rustc_diagnostic_item = "SymbolIntern"]
2812 pub fn intern(str: &str) -> Self {
2813 with_session_globals(|session_globals| session_globals.symbol_interner.intern_str(str))
2814 }
2815
2816 pub fn as_str(&self) -> &str {
2825 with_session_globals(|session_globals| unsafe {
2826 std::mem::transmute::<&str, &str>(session_globals.symbol_interner.get_str(*self))
2827 })
2828 }
2829
2830 pub fn as_u32(self) -> u32 {
2831 self.0.as_u32()
2832 }
2833
2834 pub fn is_empty(self) -> bool {
2835 self == sym::empty
2836 }
2837
2838 pub fn to_ident_string(self) -> String {
2843 if self == sym::empty { String::new() } else { Ident::with_dummy_span(self).to_string() }
2845 }
2846}
2847
2848impl fmt::Debug for Symbol {
2849 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2850 fmt::Debug::fmt(self.as_str(), f)
2851 }
2852}
2853
2854impl fmt::Display for Symbol {
2855 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2856 fmt::Display::fmt(self.as_str(), f)
2857 }
2858}
2859
2860impl<CTX> HashStable<CTX> for Symbol {
2861 #[inline]
2862 fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
2863 self.as_str().hash_stable(hcx, hasher);
2864 }
2865}
2866
2867impl<CTX> ToStableHashKey<CTX> for Symbol {
2868 type KeyType = String;
2869 #[inline]
2870 fn to_stable_hash_key(&self, _: &CTX) -> String {
2871 self.as_str().to_string()
2872 }
2873}
2874
2875impl StableCompare for Symbol {
2876 const CAN_USE_UNSTABLE_SORT: bool = true;
2877
2878 fn stable_cmp(&self, other: &Self) -> std::cmp::Ordering {
2879 self.as_str().cmp(other.as_str())
2880 }
2881}
2882
2883#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2886pub struct ByteSymbol(SymbolIndex);
2887
2888impl ByteSymbol {
2889 pub const fn new(n: u32) -> Self {
2892 ByteSymbol(SymbolIndex::from_u32(n))
2893 }
2894
2895 pub fn intern(byte_str: &[u8]) -> Self {
2897 with_session_globals(|session_globals| {
2898 session_globals.symbol_interner.intern_byte_str(byte_str)
2899 })
2900 }
2901
2902 pub fn as_byte_str(&self) -> &[u8] {
2904 with_session_globals(|session_globals| unsafe {
2905 std::mem::transmute::<&[u8], &[u8]>(session_globals.symbol_interner.get_byte_str(*self))
2906 })
2907 }
2908
2909 pub fn as_u32(self) -> u32 {
2910 self.0.as_u32()
2911 }
2912}
2913
2914impl fmt::Debug for ByteSymbol {
2915 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2916 fmt::Debug::fmt(self.as_byte_str(), f)
2917 }
2918}
2919
2920impl<CTX> HashStable<CTX> for ByteSymbol {
2921 #[inline]
2922 fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
2923 self.as_byte_str().hash_stable(hcx, hasher);
2924 }
2925}
2926
2927pub(crate) struct Interner(Lock<InternerInner>);
2932
2933struct InternerInner {
2939 arena: DroplessArena,
2940 byte_strs: FxIndexSet<&'static [u8]>,
2941}
2942
2943impl Interner {
2944 fn prefill(init: &[&'static str], extra: &[&'static str]) -> Self {
2948 let byte_strs = FxIndexSet::from_iter(
2949 init.iter().copied().chain(extra.iter().copied()).map(|str| str.as_bytes()),
2950 );
2951
2952 #[expect(rustc::potential_query_instability)]
2954 if byte_strs.len() != init.len() + extra.len() {
2955 panic!(
2956 "duplicate symbols in the rustc symbol list and the extra symbols added by the driver: {:?}",
2957 FxHashSet::intersection(
2958 &init.iter().copied().collect(),
2959 &extra.iter().copied().collect(),
2960 )
2961 .collect::<Vec<_>>()
2962 )
2963 }
2964
2965 Interner(Lock::new(InternerInner { arena: Default::default(), byte_strs }))
2966 }
2967
2968 fn intern_str(&self, str: &str) -> Symbol {
2969 Symbol::new(self.intern_inner(str.as_bytes()))
2970 }
2971
2972 fn intern_byte_str(&self, byte_str: &[u8]) -> ByteSymbol {
2973 ByteSymbol::new(self.intern_inner(byte_str))
2974 }
2975
2976 #[inline]
2977 fn intern_inner(&self, byte_str: &[u8]) -> u32 {
2978 let mut inner = self.0.lock();
2979 if let Some(idx) = inner.byte_strs.get_index_of(byte_str) {
2980 return idx as u32;
2981 }
2982
2983 let byte_str: &[u8] = inner.arena.alloc_slice(byte_str);
2984
2985 let byte_str: &'static [u8] = unsafe { &*(byte_str as *const [u8]) };
2988
2989 let (idx, is_new) = inner.byte_strs.insert_full(byte_str);
2993 debug_assert!(is_new); idx as u32
2996 }
2997
2998 fn get_str(&self, symbol: Symbol) -> &str {
3002 let byte_str = self.get_inner(symbol.0.as_usize());
3003 unsafe { str::from_utf8_unchecked(byte_str) }
3005 }
3006
3007 fn get_byte_str(&self, symbol: ByteSymbol) -> &[u8] {
3011 self.get_inner(symbol.0.as_usize())
3012 }
3013
3014 fn get_inner(&self, index: usize) -> &[u8] {
3015 self.0.lock().byte_strs.get_index(index).unwrap()
3016 }
3017}
3018
3019pub mod kw {
3025 pub use super::kw_generated::*;
3026}
3027
3028pub mod sym {
3034 use super::Symbol;
3036 pub use super::kw::MacroRules as macro_rules;
3037 #[doc(inline)]
3038 pub use super::sym_generated::*;
3039
3040 pub fn integer<N: TryInto<usize> + Copy + itoa::Integer>(n: N) -> Symbol {
3045 if let Result::Ok(idx) = n.try_into() {
3046 if idx < 10 {
3047 return Symbol::new(super::SYMBOL_DIGITS_BASE + idx as u32);
3048 }
3049 }
3050 let mut buffer = itoa::Buffer::new();
3051 let printed = buffer.format(n);
3052 Symbol::intern(printed)
3053 }
3054}
3055
3056impl Symbol {
3057 fn is_special(self) -> bool {
3058 self <= kw::Underscore
3059 }
3060
3061 fn is_used_keyword_always(self) -> bool {
3062 self >= kw::As && self <= kw::While
3063 }
3064
3065 fn is_unused_keyword_always(self) -> bool {
3066 self >= kw::Abstract && self <= kw::Yield
3067 }
3068
3069 fn is_used_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool {
3070 (self >= kw::Async && self <= kw::Dyn) && edition() >= Edition::Edition2018
3071 }
3072
3073 fn is_unused_keyword_conditional(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
3074 self == kw::Gen && edition().at_least_rust_2024()
3075 || self == kw::Try && edition().at_least_rust_2018()
3076 }
3077
3078 pub fn is_reserved(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
3079 self.is_special()
3080 || self.is_used_keyword_always()
3081 || self.is_unused_keyword_always()
3082 || self.is_used_keyword_conditional(edition)
3083 || self.is_unused_keyword_conditional(edition)
3084 }
3085
3086 pub fn is_weak(self) -> bool {
3087 self >= kw::Auto && self <= kw::Yeet
3088 }
3089
3090 pub fn is_path_segment_keyword(self) -> bool {
3092 self == kw::Super
3093 || self == kw::SelfLower
3094 || self == kw::SelfUpper
3095 || self == kw::Crate
3096 || self == kw::PathRoot
3097 || self == kw::DollarCrate
3098 }
3099
3100 pub fn is_bool_lit(self) -> bool {
3102 self == kw::True || self == kw::False
3103 }
3104
3105 pub fn can_be_raw(self) -> bool {
3107 self != sym::empty && self != kw::Underscore && !self.is_path_segment_keyword()
3108 }
3109
3110 pub fn is_predefined(index: u32) -> bool {
3114 index < PREDEFINED_SYMBOLS_COUNT
3115 }
3116}
3117
3118impl Ident {
3119 pub fn is_special(self) -> bool {
3122 self.name.is_special()
3123 }
3124
3125 pub fn is_used_keyword(self) -> bool {
3127 self.name.is_used_keyword_always()
3129 || self.name.is_used_keyword_conditional(|| self.span.edition())
3130 }
3131
3132 pub fn is_unused_keyword(self) -> bool {
3134 self.name.is_unused_keyword_always()
3136 || self.name.is_unused_keyword_conditional(|| self.span.edition())
3137 }
3138
3139 pub fn is_reserved(self) -> bool {
3141 self.name.is_reserved(|| self.span.edition())
3143 }
3144
3145 pub fn is_path_segment_keyword(self) -> bool {
3147 self.name.is_path_segment_keyword()
3148 }
3149
3150 pub fn is_raw_guess(self) -> bool {
3153 self.name.can_be_raw() && self.is_reserved()
3154 }
3155
3156 pub fn is_reserved_lifetime(self) -> bool {
3159 self.is_reserved() && ![kw::Underscore, kw::Static].contains(&self.name)
3160 }
3161
3162 pub fn is_raw_lifetime_guess(self) -> bool {
3163 if self.name.as_str() == "'" {
3166 return false;
3167 }
3168 let ident_without_apostrophe = self.without_first_quote();
3169 ident_without_apostrophe.name != self.name
3170 && ident_without_apostrophe.name.can_be_raw()
3171 && ident_without_apostrophe.is_reserved_lifetime()
3172 }
3173
3174 pub fn guess_print_mode(self) -> IdentPrintMode {
3175 if self.is_raw_lifetime_guess() {
3176 IdentPrintMode::RawLifetime
3177 } else if self.is_raw_guess() {
3178 IdentPrintMode::RawIdent
3179 } else {
3180 IdentPrintMode::Normal
3181 }
3182 }
3183
3184 pub fn is_numeric(self) -> bool {
3187 self.as_str().bytes().all(|b| b.is_ascii_digit())
3188 }
3189}
3190
3191pub fn used_keywords(edition: impl Copy + FnOnce() -> Edition) -> Vec<Symbol> {
3196 (kw::DollarCrate.as_u32()..kw::Yeet.as_u32())
3197 .filter_map(|kw| {
3198 let kw = Symbol::new(kw);
3199 if kw.is_used_keyword_always() || kw.is_used_keyword_conditional(edition) {
3200 Some(kw)
3201 } else {
3202 None
3203 }
3204 })
3205 .collect()
3206}