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