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