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