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_write,
1792 ptr_write_bytes,
1793 ptr_write_unaligned,
1794 ptr_write_volatile,
1795 pub_macro_rules,
1796 pub_restricted,
1797 public,
1798 pure,
1799 pushpop_unsafe,
1800 qreg,
1801 qreg_low4,
1802 qreg_low8,
1803 quad_precision_float,
1804 question_mark,
1805 quote,
1806 range_inclusive_new,
1807 range_step,
1808 raw_dash_dylib: "raw-dylib",
1809 raw_dylib,
1810 raw_dylib_elf,
1811 raw_eq,
1812 raw_identifiers,
1813 raw_ref_op,
1814 re_rebalance_coherence,
1815 read_enum,
1816 read_enum_variant,
1817 read_enum_variant_arg,
1818 read_struct,
1819 read_struct_field,
1820 read_via_copy,
1821 readonly,
1822 realloc,
1823 realtime,
1824 reason,
1825 reborrow,
1826 receiver,
1827 receiver_target,
1828 recursion_limit,
1829 reexport_test_harness_main,
1830 ref_pat_eat_one_layer_2024,
1831 ref_pat_eat_one_layer_2024_structural,
1832 ref_pat_everywhere,
1833 ref_unwind_safe_trait,
1834 reference,
1835 reflect,
1836 reg,
1837 reg16,
1838 reg32,
1839 reg64,
1840 reg_abcd,
1841 reg_addr,
1842 reg_byte,
1843 reg_data,
1844 reg_iw,
1845 reg_nonzero,
1846 reg_pair,
1847 reg_ptr,
1848 reg_upper,
1849 register_attr,
1850 register_tool,
1851 relaxed_adts,
1852 relaxed_struct_unsize,
1853 relocation_model,
1854 rem,
1855 rem_assign,
1856 repr,
1857 repr128,
1858 repr_align,
1859 repr_align_enum,
1860 repr_packed,
1861 repr_simd,
1862 repr_transparent,
1863 require,
1864 reserve_x18: "reserve-x18",
1865 residual,
1866 result,
1867 result_ffi_guarantees,
1868 result_ok_method,
1869 resume,
1870 return_position_impl_trait_in_trait,
1871 return_type_notation,
1872 riscv32,
1873 riscv64,
1874 riscv_target_feature,
1875 rlib,
1876 ropi,
1877 ropi_rwpi: "ropi-rwpi",
1878 rotate_left,
1879 rotate_right,
1880 round_ties_even_f16,
1881 round_ties_even_f32,
1882 round_ties_even_f64,
1883 round_ties_even_f128,
1884 roundf16,
1885 roundf32,
1886 roundf64,
1887 roundf128,
1888 rt,
1889 rtm_target_feature,
1890 runtime,
1891 rust,
1892 rust_2015,
1893 rust_2018,
1894 rust_2018_preview,
1895 rust_2021,
1896 rust_2024,
1897 rust_analyzer,
1898 rust_begin_unwind,
1899 rust_cold_cc,
1900 rust_eh_catch_typeinfo,
1901 rust_eh_personality,
1902 rust_future,
1903 rust_logo,
1904 rust_out,
1905 rustc,
1906 rustc_abi,
1907 rustc_align,
1909 rustc_align_static,
1910 rustc_allocator,
1911 rustc_allocator_zeroed,
1912 rustc_allocator_zeroed_variant,
1913 rustc_allow_const_fn_unstable,
1914 rustc_allow_incoherent_impl,
1915 rustc_allowed_through_unstable_modules,
1916 rustc_as_ptr,
1917 rustc_attrs,
1918 rustc_autodiff,
1919 rustc_builtin_macro,
1920 rustc_capture_analysis,
1921 rustc_clean,
1922 rustc_coherence_is_core,
1923 rustc_coinductive,
1924 rustc_confusables,
1925 rustc_const_stable,
1926 rustc_const_stable_indirect,
1927 rustc_const_unstable,
1928 rustc_conversion_suggestion,
1929 rustc_deallocator,
1930 rustc_def_path,
1931 rustc_default_body_unstable,
1932 rustc_delayed_bug_from_inside_query,
1933 rustc_deny_explicit_impl,
1934 rustc_deprecated_safe_2024,
1935 rustc_diagnostic_item,
1936 rustc_diagnostic_macros,
1937 rustc_dirty,
1938 rustc_do_not_const_check,
1939 rustc_do_not_implement_via_object,
1940 rustc_doc_primitive,
1941 rustc_driver,
1942 rustc_dummy,
1943 rustc_dump_def_parents,
1944 rustc_dump_item_bounds,
1945 rustc_dump_predicates,
1946 rustc_dump_user_args,
1947 rustc_dump_vtable,
1948 rustc_effective_visibility,
1949 rustc_eii_extern_item,
1950 rustc_evaluate_where_clauses,
1951 rustc_expected_cgu_reuse,
1952 rustc_force_inline,
1953 rustc_has_incoherent_inherent_impls,
1954 rustc_hidden_type_of_opaques,
1955 rustc_if_this_changed,
1956 rustc_inherit_overflow_checks,
1957 rustc_insignificant_dtor,
1958 rustc_intrinsic,
1959 rustc_intrinsic_const_stable_indirect,
1960 rustc_layout,
1961 rustc_layout_scalar_valid_range_end,
1962 rustc_layout_scalar_valid_range_start,
1963 rustc_legacy_const_generics,
1964 rustc_lint_diagnostics,
1965 rustc_lint_opt_deny_field_access,
1966 rustc_lint_opt_ty,
1967 rustc_lint_query_instability,
1968 rustc_lint_untracked_query_information,
1969 rustc_macro_transparency,
1970 rustc_main,
1971 rustc_mir,
1972 rustc_must_implement_one_of,
1973 rustc_never_returns_null_ptr,
1974 rustc_never_type_options,
1975 rustc_no_implicit_autorefs,
1976 rustc_no_implicit_bounds,
1977 rustc_no_mir_inline,
1978 rustc_nonnull_optimization_guaranteed,
1979 rustc_nounwind,
1980 rustc_objc_class,
1981 rustc_objc_selector,
1982 rustc_object_lifetime_default,
1983 rustc_offload_kernel,
1984 rustc_on_unimplemented,
1985 rustc_outlives,
1986 rustc_paren_sugar,
1987 rustc_partition_codegened,
1988 rustc_partition_reused,
1989 rustc_pass_by_value,
1990 rustc_pass_indirectly_in_non_rustic_abis,
1991 rustc_peek,
1992 rustc_peek_liveness,
1993 rustc_peek_maybe_init,
1994 rustc_peek_maybe_uninit,
1995 rustc_preserve_ub_checks,
1996 rustc_private,
1997 rustc_proc_macro_decls,
1998 rustc_promotable,
1999 rustc_pub_transparent,
2000 rustc_reallocator,
2001 rustc_regions,
2002 rustc_reservation_impl,
2003 rustc_scalable_vector,
2004 rustc_serialize,
2005 rustc_should_not_be_called_on_const_items,
2006 rustc_simd_monomorphize_lane_limit,
2007 rustc_skip_during_method_dispatch,
2008 rustc_specialization_trait,
2009 rustc_std_internal_symbol,
2010 rustc_strict_coherence,
2011 rustc_symbol_name,
2012 rustc_test_marker,
2013 rustc_then_this_would_need,
2014 rustc_trivial_field_reads,
2015 rustc_unsafe_specialization_marker,
2016 rustc_variance,
2017 rustc_variance_of_opaques,
2018 rustdoc,
2019 rustdoc_internals,
2020 rustdoc_missing_doc_code_examples,
2021 rustfmt,
2022 rvalue_static_promotion,
2023 rwpi,
2024 s,
2025 s390x,
2026 s390x_target_feature,
2027 s390x_target_feature_vector,
2028 safety,
2029 sanitize,
2030 sanitizer_cfi_generalize_pointers,
2031 sanitizer_cfi_normalize_integers,
2032 sanitizer_runtime,
2033 saturating_add,
2034 saturating_div,
2035 saturating_sub,
2036 sdylib,
2037 search_unbox,
2038 select_unpredictable,
2039 self_in_typedefs,
2040 self_struct_ctor,
2041 semiopaque,
2042 semitransparent,
2043 sha2,
2044 sha3,
2045 sha512_sm_x86,
2046 shadow_call_stack,
2047 shallow,
2048 shl,
2049 shl_assign,
2050 shorter_tail_lifetimes,
2051 should_panic,
2052 show,
2053 shr,
2054 shr_assign,
2055 sig_dfl,
2056 sig_ign,
2057 simd,
2058 simd_add,
2059 simd_and,
2060 simd_arith_offset,
2061 simd_as,
2062 simd_bitmask,
2063 simd_bitreverse,
2064 simd_bswap,
2065 simd_cast,
2066 simd_cast_ptr,
2067 simd_ceil,
2068 simd_ctlz,
2069 simd_ctpop,
2070 simd_cttz,
2071 simd_div,
2072 simd_eq,
2073 simd_expose_provenance,
2074 simd_extract,
2075 simd_extract_dyn,
2076 simd_fabs,
2077 simd_fcos,
2078 simd_fexp,
2079 simd_fexp2,
2080 simd_ffi,
2081 simd_flog,
2082 simd_flog2,
2083 simd_flog10,
2084 simd_floor,
2085 simd_fma,
2086 simd_fmax,
2087 simd_fmin,
2088 simd_fsin,
2089 simd_fsqrt,
2090 simd_funnel_shl,
2091 simd_funnel_shr,
2092 simd_gather,
2093 simd_ge,
2094 simd_gt,
2095 simd_insert,
2096 simd_insert_dyn,
2097 simd_le,
2098 simd_lt,
2099 simd_masked_load,
2100 simd_masked_store,
2101 simd_mul,
2102 simd_ne,
2103 simd_neg,
2104 simd_or,
2105 simd_reduce_add_ordered,
2106 simd_reduce_add_unordered,
2107 simd_reduce_all,
2108 simd_reduce_and,
2109 simd_reduce_any,
2110 simd_reduce_max,
2111 simd_reduce_min,
2112 simd_reduce_mul_ordered,
2113 simd_reduce_mul_unordered,
2114 simd_reduce_or,
2115 simd_reduce_xor,
2116 simd_relaxed_fma,
2117 simd_rem,
2118 simd_round,
2119 simd_round_ties_even,
2120 simd_saturating_add,
2121 simd_saturating_sub,
2122 simd_scatter,
2123 simd_select,
2124 simd_select_bitmask,
2125 simd_shl,
2126 simd_shr,
2127 simd_shuffle,
2128 simd_shuffle_const_generic,
2129 simd_sub,
2130 simd_trunc,
2131 simd_with_exposed_provenance,
2132 simd_xor,
2133 since,
2134 sinf16,
2135 sinf32,
2136 sinf64,
2137 sinf128,
2138 size,
2139 size_of,
2140 size_of_val,
2141 sized,
2142 sized_hierarchy,
2143 skip,
2144 slice,
2145 slice_from_raw_parts,
2146 slice_from_raw_parts_mut,
2147 slice_from_ref,
2148 slice_get_unchecked,
2149 slice_into_vec,
2150 slice_iter,
2151 slice_len_fn,
2152 slice_patterns,
2153 slicing_syntax,
2154 soft,
2155 sparc,
2156 sparc64,
2157 sparc_target_feature,
2158 spe_acc,
2159 specialization,
2160 speed,
2161 spirv,
2162 spotlight,
2163 sqrtf16,
2164 sqrtf32,
2165 sqrtf64,
2166 sqrtf128,
2167 sreg,
2168 sreg_low16,
2169 sse,
2170 sse2,
2171 sse4a_target_feature,
2172 stable,
2173 staged_api,
2174 start,
2175 state,
2176 static_align,
2177 static_in_const,
2178 static_nobundle,
2179 static_recursion,
2180 staticlib,
2181 std,
2182 std_lib_injection,
2183 std_panic,
2184 std_panic_2015_macro,
2185 std_panic_macro,
2186 stmt,
2187 stmt_expr_attributes,
2188 stop_after_dataflow,
2189 store,
2190 str,
2191 str_chars,
2192 str_ends_with,
2193 str_from_utf8,
2194 str_from_utf8_mut,
2195 str_from_utf8_unchecked,
2196 str_from_utf8_unchecked_mut,
2197 str_inherent_from_utf8,
2198 str_inherent_from_utf8_mut,
2199 str_inherent_from_utf8_unchecked,
2200 str_inherent_from_utf8_unchecked_mut,
2201 str_len,
2202 str_split_whitespace,
2203 str_starts_with,
2204 str_trim,
2205 str_trim_end,
2206 str_trim_start,
2207 strict_provenance_lints,
2208 string_as_mut_str,
2209 string_as_str,
2210 string_deref_patterns,
2211 string_from_utf8,
2212 string_insert_str,
2213 string_new,
2214 string_push_str,
2215 stringify,
2216 struct_field_attributes,
2217 struct_inherit,
2218 struct_variant,
2219 structural_match,
2220 structural_peq,
2221 sub,
2222 sub_assign,
2223 sub_with_overflow,
2224 suggestion,
2225 super_let,
2226 supertrait_item_shadowing,
2227 sym,
2228 sync,
2229 synthetic,
2230 sys_mutex_lock,
2231 sys_mutex_try_lock,
2232 sys_mutex_unlock,
2233 t32,
2234 target,
2235 target_abi,
2236 target_arch,
2237 target_endian,
2238 target_env,
2239 target_family,
2240 target_feature,
2241 target_feature_11,
2242 target_feature_inline_always,
2243 target_has_atomic,
2244 target_has_atomic_equal_alignment,
2245 target_has_atomic_load_store,
2246 target_has_reliable_f16,
2247 target_has_reliable_f16_math,
2248 target_has_reliable_f128,
2249 target_has_reliable_f128_math,
2250 target_os,
2251 target_pointer_width,
2252 target_thread_local,
2253 target_vendor,
2254 tbm_target_feature,
2255 termination,
2256 termination_trait,
2257 termination_trait_test,
2258 test,
2259 test_2018_feature,
2260 test_accepted_feature,
2261 test_case,
2262 test_removed_feature,
2263 test_runner,
2264 test_unstable_lint,
2265 thread,
2266 thread_local,
2267 thread_local_macro,
2268 three_way_compare,
2269 thumb2,
2270 thumb_mode: "thumb-mode",
2271 tmm_reg,
2272 to_owned_method,
2273 to_string,
2274 to_string_method,
2275 to_vec,
2276 todo_macro,
2277 tool_attributes,
2278 tool_lints,
2279 trace_macros,
2280 track_caller,
2281 trait_alias,
2282 trait_upcasting,
2283 transmute,
2284 transmute_generic_consts,
2285 transmute_opts,
2286 transmute_trait,
2287 transmute_unchecked,
2288 transparent,
2289 transparent_enums,
2290 transparent_unions,
2291 trivial_bounds,
2292 trivial_clone,
2293 truncf16,
2294 truncf32,
2295 truncf64,
2296 truncf128,
2297 try_blocks,
2298 try_blocks_heterogeneous,
2299 try_capture,
2300 try_from,
2301 try_from_fn,
2302 try_into,
2303 try_trait_v2,
2304 try_trait_v2_residual,
2305 try_update,
2306 tt,
2307 tuple,
2308 tuple_indexing,
2309 tuple_trait,
2310 two_phase,
2311 ty,
2312 type_alias_enum_variants,
2313 type_alias_impl_trait,
2314 type_ascribe,
2315 type_ascription,
2316 type_changing_struct_update,
2317 type_const,
2318 type_id,
2319 type_id_eq,
2320 type_ir,
2321 type_ir_infer_ctxt_like,
2322 type_ir_inherent,
2323 type_ir_interner,
2324 type_length_limit,
2325 type_macros,
2326 type_name,
2327 type_privacy_lints,
2328 typed_swap_nonoverlapping,
2329 u8,
2330 u8_legacy_const_max,
2331 u8_legacy_const_min,
2332 u8_legacy_fn_max_value,
2333 u8_legacy_fn_min_value,
2334 u8_legacy_mod,
2335 u16,
2336 u16_legacy_const_max,
2337 u16_legacy_const_min,
2338 u16_legacy_fn_max_value,
2339 u16_legacy_fn_min_value,
2340 u16_legacy_mod,
2341 u32,
2342 u32_legacy_const_max,
2343 u32_legacy_const_min,
2344 u32_legacy_fn_max_value,
2345 u32_legacy_fn_min_value,
2346 u32_legacy_mod,
2347 u64,
2348 u64_legacy_const_max,
2349 u64_legacy_const_min,
2350 u64_legacy_fn_max_value,
2351 u64_legacy_fn_min_value,
2352 u64_legacy_mod,
2353 u128,
2354 u128_legacy_const_max,
2355 u128_legacy_const_min,
2356 u128_legacy_fn_max_value,
2357 u128_legacy_fn_min_value,
2358 u128_legacy_mod,
2359 ub_checks,
2360 unaligned_volatile_load,
2361 unaligned_volatile_store,
2362 unboxed_closures,
2363 unchecked_add,
2364 unchecked_div,
2365 unchecked_funnel_shl,
2366 unchecked_funnel_shr,
2367 unchecked_mul,
2368 unchecked_rem,
2369 unchecked_shl,
2370 unchecked_shr,
2371 unchecked_sub,
2372 undecorated,
2373 underscore_const_names,
2374 underscore_imports,
2375 underscore_lifetimes,
2376 uniform_paths,
2377 unimplemented_macro,
2378 unit,
2379 universal_impl_trait,
2380 unix,
2381 unlikely,
2382 unmarked_api,
2383 unnamed_fields,
2384 unpin,
2385 unqualified_local_imports,
2386 unreachable,
2387 unreachable_2015,
2388 unreachable_2015_macro,
2389 unreachable_2021,
2390 unreachable_code,
2391 unreachable_display,
2392 unreachable_macro,
2393 unrestricted_attribute_tokens,
2394 unsafe_attributes,
2395 unsafe_binders,
2396 unsafe_block_in_unsafe_fn,
2397 unsafe_cell,
2398 unsafe_cell_raw_get,
2399 unsafe_eii,
2400 unsafe_extern_blocks,
2401 unsafe_fields,
2402 unsafe_no_drop_flag,
2403 unsafe_pinned,
2404 unsafe_unpin,
2405 unsize,
2406 unsized_const_param_ty,
2407 unsized_const_params,
2408 unsized_fn_params,
2409 unsized_locals,
2410 unsized_tuple_coercion,
2411 unstable,
2412 unstable_feature_bound,
2413 unstable_location_reason_default: "this crate is being loaded from the sysroot, an \
2414 unstable location; did you mean to load this crate \
2415 from crates.io via `Cargo.toml` instead?",
2416 untagged_unions,
2417 unused_imports,
2418 unwind,
2419 unwind_attributes,
2420 unwind_safe_trait,
2421 unwrap,
2422 unwrap_binder,
2423 unwrap_or,
2424 update,
2425 use_cloned,
2426 use_extern_macros,
2427 use_nested_groups,
2428 used,
2429 used_with_arg,
2430 using,
2431 usize,
2432 usize_legacy_const_max,
2433 usize_legacy_const_min,
2434 usize_legacy_fn_max_value,
2435 usize_legacy_fn_min_value,
2436 usize_legacy_mod,
2437 v1,
2438 v8plus,
2439 va_arg,
2440 va_copy,
2441 va_end,
2442 va_list,
2443 va_start,
2444 val,
2445 validity,
2446 value,
2447 values,
2448 var,
2449 variant_count,
2450 vec,
2451 vec_as_mut_slice,
2452 vec_as_slice,
2453 vec_from_elem,
2454 vec_is_empty,
2455 vec_macro,
2456 vec_new,
2457 vec_pop,
2458 vec_reserve,
2459 vec_with_capacity,
2460 vecdeque_iter,
2461 vecdeque_reserve,
2462 vector,
2463 verbatim,
2464 version,
2465 vfp2,
2466 vis,
2467 visible_private_types,
2468 volatile,
2469 volatile_copy_memory,
2470 volatile_copy_nonoverlapping_memory,
2471 volatile_load,
2472 volatile_set_memory,
2473 volatile_store,
2474 vreg,
2475 vreg_low16,
2476 vsreg,
2477 vsx,
2478 vtable_align,
2479 vtable_for,
2480 vtable_size,
2481 warn,
2482 wasip2,
2483 wasm32,
2484 wasm64,
2485 wasm_abi,
2486 wasm_import_module,
2487 wasm_target_feature,
2488 weak,
2489 weak_odr,
2490 where_clause_attrs,
2491 while_let,
2492 whole_dash_archive: "whole-archive",
2493 width,
2494 windows,
2495 windows_subsystem,
2496 with_negative_coherence,
2497 wrap_binder,
2498 wrapping_add,
2499 wrapping_div,
2500 wrapping_mul,
2501 wrapping_rem,
2502 wrapping_rem_euclid,
2503 wrapping_sub,
2504 wreg,
2505 write_bytes,
2506 write_fmt,
2507 write_macro,
2508 write_str,
2509 write_via_move,
2510 writeln_macro,
2511 x86,
2512 x86_64,
2513 x86_amx_intrinsics,
2514 x87_reg,
2515 x87_target_feature,
2516 xer,
2517 xmm_reg,
2518 xop_target_feature,
2519 xtensa,
2520 yeet_desugar_details,
2521 yeet_expr,
2522 yes,
2523 yield_expr,
2524 ymm_reg,
2525 yreg,
2526 zca,
2527 zfh,
2528 zfhmin,
2529 zmm_reg,
2530 ztso,
2531 }
2533}
2534
2535pub const STDLIB_STABLE_CRATES: &[Symbol] = &[sym::std, sym::core, sym::alloc, sym::proc_macro];
2538
2539#[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)]
2540pub struct Ident {
2541 pub name: Symbol,
2546 pub span: Span,
2547}
2548
2549impl Ident {
2550 #[inline]
2551 pub fn new(name: Symbol, span: Span) -> Ident {
2553 debug_assert_ne!(name, sym::empty);
2554 Ident { name, span }
2555 }
2556
2557 #[inline]
2559 pub fn with_dummy_span(name: Symbol) -> Ident {
2560 Ident::new(name, DUMMY_SP)
2561 }
2562
2563 #[inline]
2568 pub fn dummy() -> Ident {
2569 Ident::with_dummy_span(sym::dummy)
2570 }
2571
2572 pub fn from_str(string: &str) -> Ident {
2574 Ident::with_dummy_span(Symbol::intern(string))
2575 }
2576
2577 pub fn from_str_and_span(string: &str, span: Span) -> Ident {
2579 Ident::new(Symbol::intern(string), span)
2580 }
2581
2582 pub fn with_span_pos(self, span: Span) -> Ident {
2584 Ident::new(self.name, span.with_ctxt(self.span.ctxt()))
2585 }
2586
2587 pub fn without_first_quote(self) -> Ident {
2590 self.as_str()
2591 .strip_prefix('\'')
2592 .map_or(self, |name| Ident::new(Symbol::intern(name), self.span))
2593 }
2594
2595 pub fn normalize_to_macros_2_0(self) -> Ident {
2601 Ident::new(self.name, self.span.normalize_to_macros_2_0())
2602 }
2603
2604 #[inline]
2610 pub fn normalize_to_macro_rules(self) -> Ident {
2611 Ident::new(self.name, self.span.normalize_to_macro_rules())
2612 }
2613
2614 pub fn as_str(&self) -> &str {
2620 self.name.as_str()
2621 }
2622}
2623
2624impl PartialEq for Ident {
2625 #[inline]
2626 fn eq(&self, rhs: &Self) -> bool {
2627 self.name == rhs.name && self.span.eq_ctxt(rhs.span)
2628 }
2629}
2630
2631impl Hash for Ident {
2632 fn hash<H: Hasher>(&self, state: &mut H) {
2633 self.name.hash(state);
2634 self.span.ctxt().hash(state);
2635 }
2636}
2637
2638impl fmt::Debug for Ident {
2639 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2640 fmt::Display::fmt(self, f)?;
2641 fmt::Debug::fmt(&self.span.ctxt(), f)
2642 }
2643}
2644
2645impl fmt::Display for Ident {
2649 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2650 fmt::Display::fmt(&IdentPrinter::new(self.name, self.guess_print_mode(), None), f)
2651 }
2652}
2653
2654pub enum IdentPrintMode {
2655 Normal,
2656 RawIdent,
2657 RawLifetime,
2658}
2659
2660pub struct IdentPrinter {
2674 symbol: Symbol,
2675 mode: IdentPrintMode,
2676 convert_dollar_crate: Option<Span>,
2679}
2680
2681impl IdentPrinter {
2682 pub fn new(
2684 symbol: Symbol,
2685 mode: IdentPrintMode,
2686 convert_dollar_crate: Option<Span>,
2687 ) -> IdentPrinter {
2688 IdentPrinter { symbol, mode, convert_dollar_crate }
2689 }
2690
2691 pub fn for_ast_ident(ident: Ident, mode: IdentPrintMode) -> IdentPrinter {
2695 IdentPrinter::new(ident.name, mode, Some(ident.span))
2696 }
2697}
2698
2699impl fmt::Display for IdentPrinter {
2700 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2701 let s = match self.mode {
2702 IdentPrintMode::Normal
2703 if self.symbol == kw::DollarCrate
2704 && let Some(span) = self.convert_dollar_crate =>
2705 {
2706 let converted = span.ctxt().dollar_crate_name();
2707 if !converted.is_path_segment_keyword() {
2708 f.write_str("::")?;
2709 }
2710 converted
2711 }
2712 IdentPrintMode::Normal => self.symbol,
2713 IdentPrintMode::RawIdent => {
2714 f.write_str("r#")?;
2715 self.symbol
2716 }
2717 IdentPrintMode::RawLifetime => {
2718 f.write_str("'r#")?;
2719 let s = self
2720 .symbol
2721 .as_str()
2722 .strip_prefix("'")
2723 .expect("only lifetime idents should be passed with RawLifetime mode");
2724 Symbol::intern(s)
2725 }
2726 };
2727 s.fmt(f)
2728 }
2729}
2730
2731#[derive(Copy, Clone, Eq, PartialEq, Hash)]
2737pub struct MacroRulesNormalizedIdent(Ident);
2738
2739impl MacroRulesNormalizedIdent {
2740 #[inline]
2741 pub fn new(ident: Ident) -> Self {
2742 MacroRulesNormalizedIdent(ident.normalize_to_macro_rules())
2743 }
2744}
2745
2746impl fmt::Debug for MacroRulesNormalizedIdent {
2747 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2748 fmt::Debug::fmt(&self.0, f)
2749 }
2750}
2751
2752impl fmt::Display for MacroRulesNormalizedIdent {
2753 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2754 fmt::Display::fmt(&self.0, f)
2755 }
2756}
2757
2758#[derive(Copy, Clone, Eq, PartialEq, Hash)]
2765pub struct Macros20NormalizedIdent(pub Ident);
2766
2767impl Macros20NormalizedIdent {
2768 #[inline]
2769 pub fn new(ident: Ident) -> Self {
2770 Macros20NormalizedIdent(ident.normalize_to_macros_2_0())
2771 }
2772
2773 pub fn with_dummy_span(name: Symbol) -> Self {
2775 Macros20NormalizedIdent(Ident::with_dummy_span(name))
2776 }
2777}
2778
2779impl fmt::Debug for Macros20NormalizedIdent {
2780 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2781 fmt::Debug::fmt(&self.0, f)
2782 }
2783}
2784
2785impl fmt::Display for Macros20NormalizedIdent {
2786 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2787 fmt::Display::fmt(&self.0, f)
2788 }
2789}
2790
2791impl Deref for Macros20NormalizedIdent {
2794 type Target = Ident;
2795 fn deref(&self) -> &Self::Target {
2796 &self.0
2797 }
2798}
2799
2800#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2810pub struct Symbol(SymbolIndex);
2811
2812rustc_index::newtype_index! {
2814 #[orderable]
2815 struct SymbolIndex {}
2816}
2817
2818impl Symbol {
2819 pub const fn new(n: u32) -> Self {
2822 Symbol(SymbolIndex::from_u32(n))
2823 }
2824
2825 #[rustc_diagnostic_item = "SymbolIntern"]
2827 pub fn intern(str: &str) -> Self {
2828 with_session_globals(|session_globals| session_globals.symbol_interner.intern_str(str))
2829 }
2830
2831 pub fn as_str(&self) -> &str {
2840 with_session_globals(|session_globals| unsafe {
2841 std::mem::transmute::<&str, &str>(session_globals.symbol_interner.get_str(*self))
2842 })
2843 }
2844
2845 pub fn as_u32(self) -> u32 {
2846 self.0.as_u32()
2847 }
2848
2849 pub fn is_empty(self) -> bool {
2850 self == sym::empty
2851 }
2852
2853 pub fn to_ident_string(self) -> String {
2858 if self == sym::empty { String::new() } else { Ident::with_dummy_span(self).to_string() }
2860 }
2861
2862 pub fn find_similar(
2869 self,
2870 candidates: &[Symbol],
2871 ) -> Option<(Symbol, bool)> {
2872 let lowercase = self.as_str().to_lowercase();
2873 let lowercase_sym = Symbol::intern(&lowercase);
2874 if candidates.contains(&lowercase_sym) {
2875 Some((lowercase_sym, true))
2876 } else if let Some(similar_sym) = find_best_match_for_name(candidates, self, None) {
2877 Some((similar_sym, false))
2878 } else {
2879 None
2880 }
2881 }
2882}
2883
2884impl fmt::Debug for Symbol {
2885 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2886 fmt::Debug::fmt(self.as_str(), f)
2887 }
2888}
2889
2890impl fmt::Display for Symbol {
2891 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2892 fmt::Display::fmt(self.as_str(), f)
2893 }
2894}
2895
2896impl<CTX> HashStable<CTX> for Symbol {
2897 #[inline]
2898 fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
2899 self.as_str().hash_stable(hcx, hasher);
2900 }
2901}
2902
2903impl<CTX> ToStableHashKey<CTX> for Symbol {
2904 type KeyType = String;
2905 #[inline]
2906 fn to_stable_hash_key(&self, _: &CTX) -> String {
2907 self.as_str().to_string()
2908 }
2909}
2910
2911impl StableCompare for Symbol {
2912 const CAN_USE_UNSTABLE_SORT: bool = true;
2913
2914 fn stable_cmp(&self, other: &Self) -> std::cmp::Ordering {
2915 self.as_str().cmp(other.as_str())
2916 }
2917}
2918
2919#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2922pub struct ByteSymbol(SymbolIndex);
2923
2924impl ByteSymbol {
2925 pub const fn new(n: u32) -> Self {
2928 ByteSymbol(SymbolIndex::from_u32(n))
2929 }
2930
2931 pub fn intern(byte_str: &[u8]) -> Self {
2933 with_session_globals(|session_globals| {
2934 session_globals.symbol_interner.intern_byte_str(byte_str)
2935 })
2936 }
2937
2938 pub fn as_byte_str(&self) -> &[u8] {
2940 with_session_globals(|session_globals| unsafe {
2941 std::mem::transmute::<&[u8], &[u8]>(session_globals.symbol_interner.get_byte_str(*self))
2942 })
2943 }
2944
2945 pub fn as_u32(self) -> u32 {
2946 self.0.as_u32()
2947 }
2948}
2949
2950impl fmt::Debug for ByteSymbol {
2951 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2952 fmt::Debug::fmt(self.as_byte_str(), f)
2953 }
2954}
2955
2956impl<CTX> HashStable<CTX> for ByteSymbol {
2957 #[inline]
2958 fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
2959 self.as_byte_str().hash_stable(hcx, hasher);
2960 }
2961}
2962
2963pub(crate) struct Interner(Lock<InternerInner>);
2968
2969struct InternerInner {
2975 arena: DroplessArena,
2976 byte_strs: FxIndexSet<&'static [u8]>,
2977}
2978
2979impl Interner {
2980 fn prefill(init: &[&'static str], extra: &[&'static str]) -> Self {
2984 let byte_strs = FxIndexSet::from_iter(
2985 init.iter().copied().chain(extra.iter().copied()).map(|str| str.as_bytes()),
2986 );
2987
2988 #[expect(rustc::potential_query_instability)]
2990 if byte_strs.len() != init.len() + extra.len() {
2991 panic!(
2992 "duplicate symbols in the rustc symbol list and the extra symbols added by the driver: {:?}",
2993 FxHashSet::intersection(
2994 &init.iter().copied().collect(),
2995 &extra.iter().copied().collect(),
2996 )
2997 .collect::<Vec<_>>()
2998 )
2999 }
3000
3001 Interner(Lock::new(InternerInner { arena: Default::default(), byte_strs }))
3002 }
3003
3004 fn intern_str(&self, str: &str) -> Symbol {
3005 Symbol::new(self.intern_inner(str.as_bytes()))
3006 }
3007
3008 fn intern_byte_str(&self, byte_str: &[u8]) -> ByteSymbol {
3009 ByteSymbol::new(self.intern_inner(byte_str))
3010 }
3011
3012 #[inline]
3013 fn intern_inner(&self, byte_str: &[u8]) -> u32 {
3014 let mut inner = self.0.lock();
3015 if let Some(idx) = inner.byte_strs.get_index_of(byte_str) {
3016 return idx as u32;
3017 }
3018
3019 let byte_str: &[u8] = inner.arena.alloc_slice(byte_str);
3020
3021 let byte_str: &'static [u8] = unsafe { &*(byte_str as *const [u8]) };
3024
3025 let (idx, is_new) = inner.byte_strs.insert_full(byte_str);
3029 debug_assert!(is_new); idx as u32
3032 }
3033
3034 fn get_str(&self, symbol: Symbol) -> &str {
3038 let byte_str = self.get_inner(symbol.0.as_usize());
3039 unsafe { str::from_utf8_unchecked(byte_str) }
3041 }
3042
3043 fn get_byte_str(&self, symbol: ByteSymbol) -> &[u8] {
3047 self.get_inner(symbol.0.as_usize())
3048 }
3049
3050 fn get_inner(&self, index: usize) -> &[u8] {
3051 self.0.lock().byte_strs.get_index(index).unwrap()
3052 }
3053}
3054
3055pub mod kw {
3061 pub use super::kw_generated::*;
3062}
3063
3064pub mod sym {
3070 use super::Symbol;
3072 pub use super::kw::MacroRules as macro_rules;
3073 #[doc(inline)]
3074 pub use super::sym_generated::*;
3075
3076 pub fn integer<N: TryInto<usize> + Copy + itoa::Integer>(n: N) -> Symbol {
3081 if let Result::Ok(idx) = n.try_into() {
3082 if idx < 10 {
3083 return Symbol::new(super::SYMBOL_DIGITS_BASE + idx as u32);
3084 }
3085 }
3086 let mut buffer = itoa::Buffer::new();
3087 let printed = buffer.format(n);
3088 Symbol::intern(printed)
3089 }
3090}
3091
3092impl Symbol {
3093 fn is_special(self) -> bool {
3094 self <= kw::Underscore
3095 }
3096
3097 fn is_used_keyword_always(self) -> bool {
3098 self >= kw::As && self <= kw::While
3099 }
3100
3101 fn is_unused_keyword_always(self) -> bool {
3102 self >= kw::Abstract && self <= kw::Yield
3103 }
3104
3105 fn is_used_keyword_conditional(self, edition: impl FnOnce() -> Edition) -> bool {
3106 (self >= kw::Async && self <= kw::Dyn) && edition() >= Edition::Edition2018
3107 }
3108
3109 fn is_unused_keyword_conditional(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
3110 self == kw::Gen && edition().at_least_rust_2024()
3111 || self == kw::Try && edition().at_least_rust_2018()
3112 }
3113
3114 pub fn is_reserved(self, edition: impl Copy + FnOnce() -> Edition) -> bool {
3115 self.is_special()
3116 || self.is_used_keyword_always()
3117 || self.is_unused_keyword_always()
3118 || self.is_used_keyword_conditional(edition)
3119 || self.is_unused_keyword_conditional(edition)
3120 }
3121
3122 pub fn is_weak(self) -> bool {
3123 self >= kw::Auto && self <= kw::Yeet
3124 }
3125
3126 pub fn is_path_segment_keyword(self) -> bool {
3128 self == kw::Super
3129 || self == kw::SelfLower
3130 || self == kw::SelfUpper
3131 || self == kw::Crate
3132 || self == kw::PathRoot
3133 || self == kw::DollarCrate
3134 }
3135
3136 pub fn is_bool_lit(self) -> bool {
3138 self == kw::True || self == kw::False
3139 }
3140
3141 pub fn can_be_raw(self) -> bool {
3143 self != sym::empty && self != kw::Underscore && !self.is_path_segment_keyword()
3144 }
3145
3146 pub fn is_predefined(index: u32) -> bool {
3150 index < PREDEFINED_SYMBOLS_COUNT
3151 }
3152}
3153
3154impl Ident {
3155 pub fn is_special(self) -> bool {
3158 self.name.is_special()
3159 }
3160
3161 pub fn is_used_keyword(self) -> bool {
3163 self.name.is_used_keyword_always()
3165 || self.name.is_used_keyword_conditional(|| self.span.edition())
3166 }
3167
3168 pub fn is_unused_keyword(self) -> bool {
3170 self.name.is_unused_keyword_always()
3172 || self.name.is_unused_keyword_conditional(|| self.span.edition())
3173 }
3174
3175 pub fn is_reserved(self) -> bool {
3177 self.name.is_reserved(|| self.span.edition())
3179 }
3180
3181 pub fn is_path_segment_keyword(self) -> bool {
3183 self.name.is_path_segment_keyword()
3184 }
3185
3186 pub fn is_raw_guess(self) -> bool {
3189 self.name.can_be_raw() && self.is_reserved()
3190 }
3191
3192 pub fn is_reserved_lifetime(self) -> bool {
3195 self.is_reserved() && ![kw::Underscore, kw::Static].contains(&self.name)
3196 }
3197
3198 pub fn is_raw_lifetime_guess(self) -> bool {
3199 if self.name.as_str() == "'" {
3202 return false;
3203 }
3204 let ident_without_apostrophe = self.without_first_quote();
3205 ident_without_apostrophe.name != self.name
3206 && ident_without_apostrophe.name.can_be_raw()
3207 && ident_without_apostrophe.is_reserved_lifetime()
3208 }
3209
3210 pub fn guess_print_mode(self) -> IdentPrintMode {
3211 if self.is_raw_lifetime_guess() {
3212 IdentPrintMode::RawLifetime
3213 } else if self.is_raw_guess() {
3214 IdentPrintMode::RawIdent
3215 } else {
3216 IdentPrintMode::Normal
3217 }
3218 }
3219
3220 pub fn is_numeric(self) -> bool {
3223 self.as_str().bytes().all(|b| b.is_ascii_digit())
3224 }
3225}
3226
3227pub fn used_keywords(edition: impl Copy + FnOnce() -> Edition) -> Vec<Symbol> {
3232 (kw::DollarCrate.as_u32()..kw::Yeet.as_u32())
3233 .filter_map(|kw| {
3234 let kw = Symbol::new(kw);
3235 if kw.is_used_keyword_always() || kw.is_used_keyword_conditional(edition) {
3236 Some(kw)
3237 } else {
3238 None
3239 }
3240 })
3241 .collect()
3242}