]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_span/src/symbol.rs
Auto merge of #79673 - ijackson:intoinnerintoinnererror, r=m-ou-se
[rust.git] / compiler / rustc_span / src / symbol.rs
1 //! An "interner" is a data structure that associates values with usize tags and
2 //! allows bidirectional lookup; i.e., given a value, one can easily find the
3 //! type, and vice versa.
4
5 use rustc_arena::DroplessArena;
6 use rustc_data_structures::fx::FxHashMap;
7 use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
8 use rustc_macros::HashStable_Generic;
9 use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
10
11 use std::cmp::{Ord, PartialEq, PartialOrd};
12 use std::fmt;
13 use std::hash::{Hash, Hasher};
14 use std::str;
15
16 use crate::{Span, DUMMY_SP, SESSION_GLOBALS};
17
18 #[cfg(test)]
19 mod tests;
20
21 // The proc macro code for this is in `src/librustc_macros/src/symbols.rs`.
22 symbols! {
23     // After modifying this list adjust `is_special`, `is_used_keyword`/`is_unused_keyword`,
24     // this should be rarely necessary though if the keywords are kept in alphabetic order.
25     Keywords {
26         // Special reserved identifiers used internally for elided lifetimes,
27         // unnamed method parameters, crate root module, error recovery etc.
28         Invalid:            "",
29         PathRoot:           "{{root}}",
30         DollarCrate:        "$crate",
31         Underscore:         "_",
32
33         // Keywords that are used in stable Rust.
34         As:                 "as",
35         Break:              "break",
36         Const:              "const",
37         Continue:           "continue",
38         Crate:              "crate",
39         Else:               "else",
40         Enum:               "enum",
41         Extern:             "extern",
42         False:              "false",
43         Fn:                 "fn",
44         For:                "for",
45         If:                 "if",
46         Impl:               "impl",
47         In:                 "in",
48         Let:                "let",
49         Loop:               "loop",
50         Match:              "match",
51         Mod:                "mod",
52         Move:               "move",
53         Mut:                "mut",
54         Pub:                "pub",
55         Ref:                "ref",
56         Return:             "return",
57         SelfLower:          "self",
58         SelfUpper:          "Self",
59         Static:             "static",
60         Struct:             "struct",
61         Super:              "super",
62         Trait:              "trait",
63         True:               "true",
64         Type:               "type",
65         Unsafe:             "unsafe",
66         Use:                "use",
67         Where:              "where",
68         While:              "while",
69
70         // Keywords that are used in unstable Rust or reserved for future use.
71         Abstract:           "abstract",
72         Become:             "become",
73         Box:                "box",
74         Do:                 "do",
75         Final:              "final",
76         Macro:              "macro",
77         Override:           "override",
78         Priv:               "priv",
79         Typeof:             "typeof",
80         Unsized:            "unsized",
81         Virtual:            "virtual",
82         Yield:              "yield",
83
84         // Edition-specific keywords that are used in stable Rust.
85         Async:              "async", // >= 2018 Edition only
86         Await:              "await", // >= 2018 Edition only
87         Dyn:                "dyn", // >= 2018 Edition only
88
89         // Edition-specific keywords that are used in unstable Rust or reserved for future use.
90         Try:                "try", // >= 2018 Edition only
91
92         // Special lifetime names
93         UnderscoreLifetime: "'_",
94         StaticLifetime:     "'static",
95
96         // Weak keywords, have special meaning only in specific contexts.
97         Auto:               "auto",
98         Catch:              "catch",
99         Default:            "default",
100         MacroRules:         "macro_rules",
101         Raw:                "raw",
102         Union:              "union",
103     }
104
105     // Pre-interned symbols that can be referred to with `rustc_span::sym::*`.
106     //
107     // The symbol is the stringified identifier unless otherwise specified, in
108     // which case the name should mention the non-identifier punctuation.
109     // E.g. `sym::proc_dash_macro` represents "proc-macro", and it shouldn't be
110     // called `sym::proc_macro` because then it's easy to mistakenly think it
111     // represents "proc_macro".
112     //
113     // As well as the symbols listed, there are symbols for the strings
114     // "0", "1", ..., "9", which are accessible via `sym::integer`.
115     //
116     // The proc macro will abort if symbols are not in alphabetical order (as
117     // defined by `impl Ord for str`) or if any symbols are duplicated. Vim
118     // users can sort the list by selecting it and executing the command
119     // `:'<,'>!LC_ALL=C sort`.
120     //
121     // There is currently no checking that all symbols are used; that would be
122     // nice to have.
123     Symbols {
124         Alignment,
125         Arc,
126         Argument,
127         ArgumentV1,
128         Arguments,
129         C,
130         CString,
131         Center,
132         Clone,
133         Copy,
134         Count,
135         Debug,
136         Decodable,
137         Decoder,
138         Default,
139         Encodable,
140         Encoder,
141         Eq,
142         Equal,
143         Err,
144         Error,
145         FormatSpec,
146         Formatter,
147         From,
148         Future,
149         FxHashMap,
150         FxHashSet,
151         GlobalAlloc,
152         Hash,
153         HashMap,
154         HashSet,
155         Hasher,
156         Implied,
157         Input,
158         IntoIterator,
159         Is,
160         ItemContext,
161         Iterator,
162         Layout,
163         Left,
164         LintPass,
165         None,
166         Ok,
167         Option,
168         Ord,
169         Ordering,
170         Output,
171         Param,
172         PartialEq,
173         PartialOrd,
174         Pending,
175         Pin,
176         Poll,
177         ProcMacro,
178         ProcMacroHack,
179         ProceduralMasqueradeDummyType,
180         Range,
181         RangeFrom,
182         RangeFull,
183         RangeInclusive,
184         RangeTo,
185         RangeToInclusive,
186         Rc,
187         Ready,
188         Result,
189         Return,
190         Right,
191         RustcDecodable,
192         RustcEncodable,
193         Send,
194         Some,
195         StructuralEq,
196         StructuralPartialEq,
197         Sync,
198         Target,
199         Try,
200         Ty,
201         TyCtxt,
202         TyKind,
203         Unknown,
204         Vec,
205         Yield,
206         _DECLS,
207         _Self,
208         __D,
209         __H,
210         __S,
211         __next,
212         __try_var,
213         _d,
214         _e,
215         _task_context,
216         a32,
217         aarch64_target_feature,
218         abi,
219         abi_amdgpu_kernel,
220         abi_avr_interrupt,
221         abi_efiapi,
222         abi_msp430_interrupt,
223         abi_ptx,
224         abi_sysv64,
225         abi_thiscall,
226         abi_unadjusted,
227         abi_vectorcall,
228         abi_x86_interrupt,
229         abort,
230         aborts,
231         add,
232         add_assign,
233         add_with_overflow,
234         address,
235         advanced_slice_patterns,
236         adx_target_feature,
237         alias,
238         align,
239         align_offset,
240         alignstack,
241         all,
242         alloc,
243         alloc_error_handler,
244         alloc_layout,
245         alloc_zeroed,
246         allocator,
247         allocator_internals,
248         allow,
249         allow_fail,
250         allow_internal_unsafe,
251         allow_internal_unstable,
252         allow_internal_unstable_backcompat_hack,
253         allowed,
254         always,
255         and,
256         and_then,
257         any,
258         arbitrary_enum_discriminant,
259         arbitrary_self_types,
260         arith_offset,
261         arm,
262         arm_target_feature,
263         array,
264         arrays,
265         as_ptr,
266         as_str,
267         asm,
268         assert,
269         assert_inhabited,
270         assert_macro,
271         assert_receiver_is_total_eq,
272         assert_uninit_valid,
273         assert_zero_valid,
274         associated_consts,
275         associated_type_bounds,
276         associated_type_defaults,
277         associated_types,
278         assume,
279         assume_init,
280         async_await,
281         async_closure,
282         atomics,
283         att_syntax,
284         attr,
285         attr_literals,
286         attributes,
287         augmented_assignments,
288         auto_traits,
289         automatically_derived,
290         avx512_target_feature,
291         await_macro,
292         bang,
293         begin_panic,
294         bench,
295         bin,
296         bind_by_move_pattern_guards,
297         bindings_after_at,
298         bitand,
299         bitand_assign,
300         bitor,
301         bitor_assign,
302         bitreverse,
303         bitxor,
304         bitxor_assign,
305         block,
306         bool,
307         borrowck_graphviz_format,
308         borrowck_graphviz_postflow,
309         borrowck_graphviz_preflow,
310         box_free,
311         box_patterns,
312         box_syntax,
313         braced_empty_structs,
314         breakpoint,
315         bridge,
316         bswap,
317         c_str,
318         c_variadic,
319         call,
320         call_mut,
321         call_once,
322         caller_location,
323         capture_disjoint_fields,
324         cdylib,
325         ceilf32,
326         ceilf64,
327         cfg,
328         cfg_accessible,
329         cfg_attr,
330         cfg_attr_multi,
331         cfg_doctest,
332         cfg_panic,
333         cfg_sanitize,
334         cfg_target_feature,
335         cfg_target_has_atomic,
336         cfg_target_thread_local,
337         cfg_target_vendor,
338         cfg_version,
339         char,
340         client,
341         clippy,
342         clone,
343         clone_closures,
344         clone_from,
345         closure,
346         closure_to_fn_coercion,
347         cmp,
348         cmpxchg16b_target_feature,
349         cmse_nonsecure_entry,
350         coerce_unsized,
351         cold,
352         column,
353         compile_error,
354         compiler_builtins,
355         concat,
356         concat_idents,
357         conservative_impl_trait,
358         console,
359         const_allocate,
360         const_compare_raw_pointers,
361         const_constructor,
362         const_eval_limit,
363         const_evaluatable_checked,
364         const_extern_fn,
365         const_fn,
366         const_fn_floating_point_arithmetic,
367         const_fn_fn_ptr_basics,
368         const_fn_transmute,
369         const_fn_union,
370         const_generics,
371         const_if_match,
372         const_impl_trait,
373         const_in_array_repeat_expressions,
374         const_indexing,
375         const_let,
376         const_loop,
377         const_mut_refs,
378         const_panic,
379         const_precise_live_drops,
380         const_ptr,
381         const_raw_ptr_deref,
382         const_raw_ptr_to_usize_cast,
383         const_slice_ptr,
384         const_trait_bound_opt_out,
385         const_trait_impl,
386         const_transmute,
387         constant,
388         constructor,
389         contents,
390         context,
391         convert,
392         copy,
393         copy_closures,
394         copy_nonoverlapping,
395         copysignf32,
396         copysignf64,
397         core,
398         core_intrinsics,
399         core_panic_macro,
400         cosf32,
401         cosf64,
402         crate_id,
403         crate_in_paths,
404         crate_local,
405         crate_name,
406         crate_type,
407         crate_visibility_modifier,
408         crt_dash_static: "crt-static",
409         cstring_type,
410         ctlz,
411         ctlz_nonzero,
412         ctpop,
413         cttz,
414         cttz_nonzero,
415         custom_attribute,
416         custom_derive,
417         custom_inner_attributes,
418         custom_test_frameworks,
419         d,
420         dead_code,
421         dealloc,
422         debug,
423         debug_assert_macro,
424         debug_assertions,
425         debug_struct,
426         debug_trait,
427         debug_trait_builder,
428         debug_tuple,
429         decl_macro,
430         declare_lint_pass,
431         decode,
432         default_alloc_error_handler,
433         default_lib_allocator,
434         default_type_parameter_fallback,
435         default_type_params,
436         delay_span_bug_from_inside_query,
437         deny,
438         deprecated,
439         deref,
440         deref_method,
441         deref_mut,
442         deref_target,
443         derive,
444         destructuring_assignment,
445         diagnostic,
446         direct,
447         discriminant_kind,
448         discriminant_type,
449         discriminant_value,
450         dispatch_from_dyn,
451         div,
452         div_assign,
453         doc,
454         doc_alias,
455         doc_cfg,
456         doc_keyword,
457         doc_masked,
458         doc_spotlight,
459         doctest,
460         document_private_items,
461         dotdot_in_tuple_patterns,
462         dotdoteq_in_patterns,
463         drop,
464         drop_in_place,
465         drop_types_in_const,
466         dropck_eyepatch,
467         dropck_parametricity,
468         dylib,
469         dyn_trait,
470         eh_catch_typeinfo,
471         eh_personality,
472         emit_enum,
473         emit_enum_variant,
474         emit_enum_variant_arg,
475         emit_struct,
476         emit_struct_field,
477         enable,
478         enclosing_scope,
479         encode,
480         env,
481         eq,
482         ermsb_target_feature,
483         err,
484         exact_div,
485         except,
486         exchange_malloc,
487         exclusive_range_pattern,
488         exhaustive_integer_patterns,
489         exhaustive_patterns,
490         existential_type,
491         exp2f32,
492         exp2f64,
493         expect,
494         expected,
495         expf32,
496         expf64,
497         export_name,
498         expr,
499         extern_absolute_paths,
500         extern_crate_item_prelude,
501         extern_crate_self,
502         extern_in_paths,
503         extern_prelude,
504         extern_types,
505         external_doc,
506         f,
507         f16c_target_feature,
508         f32,
509         f32_runtime,
510         f64,
511         f64_runtime,
512         fabsf32,
513         fabsf64,
514         fadd_fast,
515         fdiv_fast,
516         feature,
517         ffi,
518         ffi_const,
519         ffi_pure,
520         ffi_returns_twice,
521         field,
522         field_init_shorthand,
523         file,
524         fill,
525         finish,
526         flags,
527         float_to_int_unchecked,
528         floorf32,
529         floorf64,
530         fmaf32,
531         fmaf64,
532         fmt,
533         fmt_internals,
534         fmul_fast,
535         fn_must_use,
536         fn_mut,
537         fn_once,
538         fn_once_output,
539         forbid,
540         forget,
541         format,
542         format_args,
543         format_args_capture,
544         format_args_nl,
545         freeze,
546         frem_fast,
547         from,
548         from_desugaring,
549         from_error,
550         from_generator,
551         from_method,
552         from_ok,
553         from_size_align_unchecked,
554         from_trait,
555         from_usize,
556         fsub_fast,
557         fundamental,
558         future,
559         future_trait,
560         ge,
561         gen_future,
562         gen_kill,
563         generator,
564         generator_state,
565         generators,
566         generic_associated_types,
567         generic_param_attrs,
568         get_context,
569         global_allocator,
570         global_asm,
571         globs,
572         gt,
573         half_open_range_patterns,
574         hash,
575         hexagon_target_feature,
576         hidden,
577         homogeneous_aggregate,
578         html_favicon_url,
579         html_logo_url,
580         html_no_source,
581         html_playground_url,
582         html_root_url,
583         i,
584         i128,
585         i128_type,
586         i16,
587         i32,
588         i64,
589         i8,
590         ident,
591         if_let,
592         if_let_guard,
593         if_while_or_patterns,
594         ignore,
595         impl_header_lifetime_elision,
596         impl_lint_pass,
597         impl_macros,
598         impl_trait_in_bindings,
599         import_shadowing,
600         in_band_lifetimes,
601         include,
602         include_bytes,
603         include_str,
604         inclusive_range_syntax,
605         index,
606         index_mut,
607         infer_outlives_requirements,
608         infer_static_outlives_requirements,
609         inlateout,
610         inline,
611         inline_const,
612         inout,
613         instruction_set,
614         intel,
615         into_iter,
616         into_result,
617         intrinsics,
618         irrefutable_let_patterns,
619         isa_attribute,
620         isize,
621         issue,
622         issue_5723_bootstrap,
623         issue_tracker_base_url,
624         item,
625         item_like_imports,
626         iter,
627         keyword,
628         kind,
629         label,
630         label_break_value,
631         lang,
632         lang_items,
633         lateout,
634         lazy_normalization_consts,
635         le,
636         let_chains,
637         lhs,
638         lib,
639         libc,
640         lifetime,
641         likely,
642         line,
643         link,
644         link_args,
645         link_cfg,
646         link_llvm_intrinsics,
647         link_name,
648         link_ordinal,
649         link_section,
650         linkage,
651         lint_reasons,
652         literal,
653         llvm_asm,
654         local_inner_macros,
655         log10f32,
656         log10f64,
657         log2f32,
658         log2f64,
659         log_syntax,
660         logf32,
661         logf64,
662         loop_break_value,
663         lt,
664         macro_at_most_once_rep,
665         macro_escape,
666         macro_export,
667         macro_lifetime_matcher,
668         macro_literal_matcher,
669         macro_reexport,
670         macro_use,
671         macro_vis_matcher,
672         macros_in_extern,
673         main,
674         managed_boxes,
675         manually_drop,
676         map,
677         marker,
678         marker_trait_attr,
679         masked,
680         match_beginning_vert,
681         match_default_bindings,
682         maxnumf32,
683         maxnumf64,
684         may_dangle,
685         maybe_uninit,
686         maybe_uninit_uninit,
687         maybe_uninit_zeroed,
688         mem_uninitialized,
689         mem_zeroed,
690         member_constraints,
691         memory,
692         message,
693         meta,
694         min_align_of,
695         min_align_of_val,
696         min_const_fn,
697         min_const_generics,
698         min_const_unsafe_fn,
699         min_specialization,
700         minnumf32,
701         minnumf64,
702         mips_target_feature,
703         misc,
704         module,
705         module_path,
706         more_struct_aliases,
707         movbe_target_feature,
708         move_ref_pattern,
709         move_val_init,
710         mul,
711         mul_assign,
712         mul_with_overflow,
713         must_use,
714         mut_ptr,
715         mut_slice_ptr,
716         naked,
717         naked_functions,
718         name,
719         ne,
720         nearbyintf32,
721         nearbyintf64,
722         needs_allocator,
723         needs_drop,
724         needs_panic_runtime,
725         neg,
726         negate_unsigned,
727         negative_impls,
728         never,
729         never_type,
730         never_type_fallback,
731         new,
732         new_unchecked,
733         next,
734         nll,
735         no,
736         no_builtins,
737         no_core,
738         no_crate_inject,
739         no_debug,
740         no_default_passes,
741         no_implicit_prelude,
742         no_inline,
743         no_link,
744         no_main,
745         no_mangle,
746         no_niche,
747         no_sanitize,
748         no_stack_check,
749         no_start,
750         no_std,
751         nomem,
752         non_ascii_idents,
753         non_exhaustive,
754         non_modrs_mods,
755         none_error,
756         nontemporal_store,
757         nontrapping_dash_fptoint: "nontrapping-fptoint",
758         noreturn,
759         nostack,
760         not,
761         note,
762         object_safe_for_dispatch,
763         of,
764         offset,
765         omit_gdb_pretty_printer_section,
766         on,
767         on_unimplemented,
768         oom,
769         opaque,
770         ops,
771         opt_out_copy,
772         optimize,
773         optimize_attribute,
774         optin_builtin_traits,
775         option,
776         option_env,
777         option_type,
778         options,
779         or,
780         or_patterns,
781         other,
782         out,
783         overlapping_marker_traits,
784         owned_box,
785         packed,
786         panic,
787         panic_abort,
788         panic_bounds_check,
789         panic_handler,
790         panic_impl,
791         panic_implementation,
792         panic_info,
793         panic_location,
794         panic_runtime,
795         panic_str,
796         panic_unwind,
797         panicking,
798         param_attrs,
799         parent_trait,
800         partial_cmp,
801         partial_ord,
802         passes,
803         pat,
804         path,
805         pattern_parentheses,
806         phantom_data,
807         pin,
808         pinned,
809         platform_intrinsics,
810         plugin,
811         plugin_registrar,
812         plugins,
813         pointer,
814         pointer_trait,
815         pointer_trait_fmt,
816         poll,
817         position,
818         post_dash_lto: "post-lto",
819         powerpc_target_feature,
820         powf32,
821         powf64,
822         powif32,
823         powif64,
824         pre_dash_lto: "pre-lto",
825         precise_pointer_size_matching,
826         precision,
827         pref_align_of,
828         prefetch_read_data,
829         prefetch_read_instruction,
830         prefetch_write_data,
831         prefetch_write_instruction,
832         prelude,
833         prelude_import,
834         preserves_flags,
835         primitive,
836         proc_dash_macro: "proc-macro",
837         proc_macro,
838         proc_macro_attribute,
839         proc_macro_def_site,
840         proc_macro_derive,
841         proc_macro_expr,
842         proc_macro_gen,
843         proc_macro_hygiene,
844         proc_macro_internals,
845         proc_macro_mod,
846         proc_macro_non_items,
847         proc_macro_path_invoc,
848         profiler_builtins,
849         profiler_runtime,
850         ptr_guaranteed_eq,
851         ptr_guaranteed_ne,
852         ptr_offset_from,
853         pub_restricted,
854         pure,
855         pushpop_unsafe,
856         quad_precision_float,
857         question_mark,
858         quote,
859         range_inclusive_new,
860         raw_dylib,
861         raw_identifiers,
862         raw_ref_op,
863         re_rebalance_coherence,
864         read_enum,
865         read_enum_variant,
866         read_enum_variant_arg,
867         read_struct,
868         read_struct_field,
869         readonly,
870         realloc,
871         reason,
872         receiver,
873         recursion_limit,
874         reexport_test_harness_main,
875         reference,
876         reflect,
877         register_attr,
878         register_tool,
879         relaxed_adts,
880         rem,
881         rem_assign,
882         repr,
883         repr128,
884         repr_align,
885         repr_align_enum,
886         repr_no_niche,
887         repr_packed,
888         repr_simd,
889         repr_transparent,
890         result,
891         result_type,
892         rhs,
893         rintf32,
894         rintf64,
895         riscv_target_feature,
896         rlib,
897         rotate_left,
898         rotate_right,
899         roundf32,
900         roundf64,
901         rt,
902         rtm_target_feature,
903         rust,
904         rust_2015_preview,
905         rust_2018_preview,
906         rust_begin_unwind,
907         rust_eh_catch_typeinfo,
908         rust_eh_personality,
909         rust_eh_register_frames,
910         rust_eh_unregister_frames,
911         rust_oom,
912         rustc,
913         rustc_allocator,
914         rustc_allocator_nounwind,
915         rustc_allow_const_fn_unstable,
916         rustc_args_required_const,
917         rustc_attrs,
918         rustc_builtin_macro,
919         rustc_capture_analysis,
920         rustc_clean,
921         rustc_const_stable,
922         rustc_const_unstable,
923         rustc_conversion_suggestion,
924         rustc_def_path,
925         rustc_deprecated,
926         rustc_diagnostic_item,
927         rustc_diagnostic_macros,
928         rustc_dirty,
929         rustc_dummy,
930         rustc_dump_env_program_clauses,
931         rustc_dump_program_clauses,
932         rustc_dump_user_substs,
933         rustc_error,
934         rustc_expected_cgu_reuse,
935         rustc_if_this_changed,
936         rustc_inherit_overflow_checks,
937         rustc_layout,
938         rustc_layout_scalar_valid_range_end,
939         rustc_layout_scalar_valid_range_start,
940         rustc_macro_transparency,
941         rustc_mir,
942         rustc_nonnull_optimization_guaranteed,
943         rustc_object_lifetime_default,
944         rustc_on_unimplemented,
945         rustc_outlives,
946         rustc_paren_sugar,
947         rustc_partition_codegened,
948         rustc_partition_reused,
949         rustc_peek,
950         rustc_peek_definite_init,
951         rustc_peek_indirectly_mutable,
952         rustc_peek_liveness,
953         rustc_peek_maybe_init,
954         rustc_peek_maybe_uninit,
955         rustc_polymorphize_error,
956         rustc_private,
957         rustc_proc_macro_decls,
958         rustc_promotable,
959         rustc_regions,
960         rustc_reservation_impl,
961         rustc_serialize,
962         rustc_specialization_trait,
963         rustc_stable,
964         rustc_std_internal_symbol,
965         rustc_symbol_name,
966         rustc_synthetic,
967         rustc_test_marker,
968         rustc_then_this_would_need,
969         rustc_unsafe_specialization_marker,
970         rustc_variance,
971         rustfmt,
972         rvalue_static_promotion,
973         sanitize,
974         sanitizer_runtime,
975         saturating_add,
976         saturating_sub,
977         self_in_typedefs,
978         self_struct_ctor,
979         semitransparent,
980         send_trait,
981         shl,
982         shl_assign,
983         should_panic,
984         shr,
985         shr_assign,
986         simd,
987         simd_add,
988         simd_and,
989         simd_bitmask,
990         simd_cast,
991         simd_ceil,
992         simd_div,
993         simd_eq,
994         simd_extract,
995         simd_fabs,
996         simd_fcos,
997         simd_fexp,
998         simd_fexp2,
999         simd_ffi,
1000         simd_flog,
1001         simd_flog10,
1002         simd_flog2,
1003         simd_floor,
1004         simd_fma,
1005         simd_fmax,
1006         simd_fmin,
1007         simd_fpow,
1008         simd_fpowi,
1009         simd_fsin,
1010         simd_fsqrt,
1011         simd_gather,
1012         simd_ge,
1013         simd_gt,
1014         simd_insert,
1015         simd_le,
1016         simd_lt,
1017         simd_mul,
1018         simd_ne,
1019         simd_or,
1020         simd_reduce_add_ordered,
1021         simd_reduce_add_unordered,
1022         simd_reduce_all,
1023         simd_reduce_and,
1024         simd_reduce_any,
1025         simd_reduce_max,
1026         simd_reduce_max_nanless,
1027         simd_reduce_min,
1028         simd_reduce_min_nanless,
1029         simd_reduce_mul_ordered,
1030         simd_reduce_mul_unordered,
1031         simd_reduce_or,
1032         simd_reduce_xor,
1033         simd_rem,
1034         simd_saturating_add,
1035         simd_saturating_sub,
1036         simd_scatter,
1037         simd_select,
1038         simd_select_bitmask,
1039         simd_shl,
1040         simd_shr,
1041         simd_sub,
1042         simd_xor,
1043         since,
1044         sinf32,
1045         sinf64,
1046         size,
1047         size_of,
1048         size_of_val,
1049         sized,
1050         slice,
1051         slice_alloc,
1052         slice_patterns,
1053         slice_u8,
1054         slice_u8_alloc,
1055         slicing_syntax,
1056         soft,
1057         specialization,
1058         speed,
1059         spotlight,
1060         sqrtf32,
1061         sqrtf64,
1062         sse4a_target_feature,
1063         stable,
1064         staged_api,
1065         start,
1066         state,
1067         static_in_const,
1068         static_nobundle,
1069         static_recursion,
1070         staticlib,
1071         std,
1072         std_inject,
1073         std_panic_macro,
1074         stmt,
1075         stmt_expr_attributes,
1076         stop_after_dataflow,
1077         str,
1078         str_alloc,
1079         string_type,
1080         stringify,
1081         struct_field_attributes,
1082         struct_inherit,
1083         struct_variant,
1084         structural_match,
1085         structural_peq,
1086         structural_teq,
1087         sty,
1088         sub,
1089         sub_assign,
1090         sub_with_overflow,
1091         suggestion,
1092         sym,
1093         sync,
1094         sync_trait,
1095         t32,
1096         target_arch,
1097         target_endian,
1098         target_env,
1099         target_family,
1100         target_feature,
1101         target_feature_11,
1102         target_has_atomic,
1103         target_has_atomic_equal_alignment,
1104         target_has_atomic_load_store,
1105         target_os,
1106         target_pointer_width,
1107         target_target_vendor,
1108         target_thread_local,
1109         target_vendor,
1110         task,
1111         tbm_target_feature,
1112         termination,
1113         termination_trait,
1114         termination_trait_test,
1115         test,
1116         test_2018_feature,
1117         test_accepted_feature,
1118         test_case,
1119         test_removed_feature,
1120         test_runner,
1121         then_with,
1122         thread,
1123         thread_local,
1124         tool_attributes,
1125         tool_lints,
1126         trace_macros,
1127         track_caller,
1128         trait_alias,
1129         transmute,
1130         transparent,
1131         transparent_enums,
1132         transparent_unions,
1133         trivial_bounds,
1134         truncf32,
1135         truncf64,
1136         try_blocks,
1137         try_trait,
1138         tt,
1139         tuple,
1140         tuple_from_req,
1141         tuple_indexing,
1142         two_phase,
1143         ty,
1144         type_alias_enum_variants,
1145         type_alias_impl_trait,
1146         type_ascription,
1147         type_id,
1148         type_length_limit,
1149         type_macros,
1150         type_name,
1151         u128,
1152         u16,
1153         u32,
1154         u64,
1155         u8,
1156         unaligned_volatile_load,
1157         unaligned_volatile_store,
1158         unboxed_closures,
1159         unchecked_add,
1160         unchecked_div,
1161         unchecked_mul,
1162         unchecked_rem,
1163         unchecked_shl,
1164         unchecked_shr,
1165         unchecked_sub,
1166         underscore_const_names,
1167         underscore_imports,
1168         underscore_lifetimes,
1169         uniform_paths,
1170         unit,
1171         universal_impl_trait,
1172         unix,
1173         unlikely,
1174         unmarked_api,
1175         unpin,
1176         unreachable,
1177         unreachable_code,
1178         unrestricted_attribute_tokens,
1179         unsafe_block_in_unsafe_fn,
1180         unsafe_cell,
1181         unsafe_no_drop_flag,
1182         unsize,
1183         unsized_fn_params,
1184         unsized_locals,
1185         unsized_tuple_coercion,
1186         unstable,
1187         untagged_unions,
1188         unused_qualifications,
1189         unwind,
1190         unwind_attributes,
1191         unwrap,
1192         unwrap_or,
1193         use_extern_macros,
1194         use_nested_groups,
1195         used,
1196         usize,
1197         v1,
1198         va_arg,
1199         va_copy,
1200         va_end,
1201         va_list,
1202         va_start,
1203         val,
1204         var,
1205         variant_count,
1206         vec,
1207         vec_type,
1208         version,
1209         vis,
1210         visible_private_types,
1211         volatile,
1212         volatile_copy_memory,
1213         volatile_copy_nonoverlapping_memory,
1214         volatile_load,
1215         volatile_set_memory,
1216         volatile_store,
1217         warn,
1218         wasm_import_module,
1219         wasm_target_feature,
1220         while_let,
1221         width,
1222         windows,
1223         windows_subsystem,
1224         wrapping_add,
1225         wrapping_mul,
1226         wrapping_sub,
1227         write_bytes,
1228     }
1229 }
1230
1231 #[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)]
1232 pub struct Ident {
1233     pub name: Symbol,
1234     pub span: Span,
1235 }
1236
1237 impl Ident {
1238     #[inline]
1239     /// Constructs a new identifier from a symbol and a span.
1240     pub const fn new(name: Symbol, span: Span) -> Ident {
1241         Ident { name, span }
1242     }
1243
1244     /// Constructs a new identifier with a dummy span.
1245     #[inline]
1246     pub const fn with_dummy_span(name: Symbol) -> Ident {
1247         Ident::new(name, DUMMY_SP)
1248     }
1249
1250     #[inline]
1251     pub fn invalid() -> Ident {
1252         Ident::with_dummy_span(kw::Invalid)
1253     }
1254
1255     /// Maps a string to an identifier with a dummy span.
1256     pub fn from_str(string: &str) -> Ident {
1257         Ident::with_dummy_span(Symbol::intern(string))
1258     }
1259
1260     /// Maps a string and a span to an identifier.
1261     pub fn from_str_and_span(string: &str, span: Span) -> Ident {
1262         Ident::new(Symbol::intern(string), span)
1263     }
1264
1265     /// Replaces `lo` and `hi` with those from `span`, but keep hygiene context.
1266     pub fn with_span_pos(self, span: Span) -> Ident {
1267         Ident::new(self.name, span.with_ctxt(self.span.ctxt()))
1268     }
1269
1270     pub fn without_first_quote(self) -> Ident {
1271         Ident::new(Symbol::intern(self.as_str().trim_start_matches('\'')), self.span)
1272     }
1273
1274     /// "Normalize" ident for use in comparisons using "item hygiene".
1275     /// Identifiers with same string value become same if they came from the same macro 2.0 macro
1276     /// (e.g., `macro` item, but not `macro_rules` item) and stay different if they came from
1277     /// different macro 2.0 macros.
1278     /// Technically, this operation strips all non-opaque marks from ident's syntactic context.
1279     pub fn normalize_to_macros_2_0(self) -> Ident {
1280         Ident::new(self.name, self.span.normalize_to_macros_2_0())
1281     }
1282
1283     /// "Normalize" ident for use in comparisons using "local variable hygiene".
1284     /// Identifiers with same string value become same if they came from the same non-transparent
1285     /// macro (e.g., `macro` or `macro_rules!` items) and stay different if they came from different
1286     /// non-transparent macros.
1287     /// Technically, this operation strips all transparent marks from ident's syntactic context.
1288     pub fn normalize_to_macro_rules(self) -> Ident {
1289         Ident::new(self.name, self.span.normalize_to_macro_rules())
1290     }
1291
1292     /// Convert the name to a `SymbolStr`. This is a slowish operation because
1293     /// it requires locking the symbol interner.
1294     pub fn as_str(self) -> SymbolStr {
1295         self.name.as_str()
1296     }
1297 }
1298
1299 impl PartialEq for Ident {
1300     fn eq(&self, rhs: &Self) -> bool {
1301         self.name == rhs.name && self.span.ctxt() == rhs.span.ctxt()
1302     }
1303 }
1304
1305 impl Hash for Ident {
1306     fn hash<H: Hasher>(&self, state: &mut H) {
1307         self.name.hash(state);
1308         self.span.ctxt().hash(state);
1309     }
1310 }
1311
1312 impl fmt::Debug for Ident {
1313     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1314         fmt::Display::fmt(self, f)?;
1315         fmt::Debug::fmt(&self.span.ctxt(), f)
1316     }
1317 }
1318
1319 /// This implementation is supposed to be used in error messages, so it's expected to be identical
1320 /// to printing the original identifier token written in source code (`token_to_string`),
1321 /// except that AST identifiers don't keep the rawness flag, so we have to guess it.
1322 impl fmt::Display for Ident {
1323     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1324         fmt::Display::fmt(&IdentPrinter::new(self.name, self.is_raw_guess(), None), f)
1325     }
1326 }
1327
1328 /// This is the most general way to print identifiers.
1329 /// AST pretty-printer is used as a fallback for turning AST structures into token streams for
1330 /// proc macros. Additionally, proc macros may stringify their input and expect it survive the
1331 /// stringification (especially true for proc macro derives written between Rust 1.15 and 1.30).
1332 /// So we need to somehow pretty-print `$crate` in a way preserving at least some of its
1333 /// hygiene data, most importantly name of the crate it refers to.
1334 /// As a result we print `$crate` as `crate` if it refers to the local crate
1335 /// and as `::other_crate_name` if it refers to some other crate.
1336 /// Note, that this is only done if the ident token is printed from inside of AST pretty-pringing,
1337 /// but not otherwise. Pretty-printing is the only way for proc macros to discover token contents,
1338 /// so we should not perform this lossy conversion if the top level call to the pretty-printer was
1339 /// done for a token stream or a single token.
1340 pub struct IdentPrinter {
1341     symbol: Symbol,
1342     is_raw: bool,
1343     /// Span used for retrieving the crate name to which `$crate` refers to,
1344     /// if this field is `None` then the `$crate` conversion doesn't happen.
1345     convert_dollar_crate: Option<Span>,
1346 }
1347
1348 impl IdentPrinter {
1349     /// The most general `IdentPrinter` constructor. Do not use this.
1350     pub fn new(symbol: Symbol, is_raw: bool, convert_dollar_crate: Option<Span>) -> IdentPrinter {
1351         IdentPrinter { symbol, is_raw, convert_dollar_crate }
1352     }
1353
1354     /// This implementation is supposed to be used when printing identifiers
1355     /// as a part of pretty-printing for larger AST pieces.
1356     /// Do not use this either.
1357     pub fn for_ast_ident(ident: Ident, is_raw: bool) -> IdentPrinter {
1358         IdentPrinter::new(ident.name, is_raw, Some(ident.span))
1359     }
1360 }
1361
1362 impl fmt::Display for IdentPrinter {
1363     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1364         if self.is_raw {
1365             f.write_str("r#")?;
1366         } else if self.symbol == kw::DollarCrate {
1367             if let Some(span) = self.convert_dollar_crate {
1368                 let converted = span.ctxt().dollar_crate_name();
1369                 if !converted.is_path_segment_keyword() {
1370                     f.write_str("::")?;
1371                 }
1372                 return fmt::Display::fmt(&converted, f);
1373             }
1374         }
1375         fmt::Display::fmt(&self.symbol, f)
1376     }
1377 }
1378
1379 /// An newtype around `Ident` that calls [Ident::normalize_to_macro_rules] on
1380 /// construction.
1381 // FIXME(matthewj, petrochenkov) Use this more often, add a similar
1382 // `ModernIdent` struct and use that as well.
1383 #[derive(Copy, Clone, Eq, PartialEq, Hash)]
1384 pub struct MacroRulesNormalizedIdent(Ident);
1385
1386 impl MacroRulesNormalizedIdent {
1387     pub fn new(ident: Ident) -> Self {
1388         Self(ident.normalize_to_macro_rules())
1389     }
1390 }
1391
1392 impl fmt::Debug for MacroRulesNormalizedIdent {
1393     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1394         fmt::Debug::fmt(&self.0, f)
1395     }
1396 }
1397
1398 impl fmt::Display for MacroRulesNormalizedIdent {
1399     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1400         fmt::Display::fmt(&self.0, f)
1401     }
1402 }
1403
1404 /// An interned string.
1405 ///
1406 /// Internally, a `Symbol` is implemented as an index, and all operations
1407 /// (including hashing, equality, and ordering) operate on that index. The use
1408 /// of `rustc_index::newtype_index!` means that `Option<Symbol>` only takes up 4 bytes,
1409 /// because `rustc_index::newtype_index!` reserves the last 256 values for tagging purposes.
1410 ///
1411 /// Note that `Symbol` cannot directly be a `rustc_index::newtype_index!` because it
1412 /// implements `fmt::Debug`, `Encodable`, and `Decodable` in special ways.
1413 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1414 pub struct Symbol(SymbolIndex);
1415
1416 rustc_index::newtype_index! {
1417     pub struct SymbolIndex { .. }
1418 }
1419
1420 impl Symbol {
1421     const fn new(n: u32) -> Self {
1422         Symbol(SymbolIndex::from_u32(n))
1423     }
1424
1425     /// Maps a string to its interned representation.
1426     pub fn intern(string: &str) -> Self {
1427         with_interner(|interner| interner.intern(string))
1428     }
1429
1430     /// Access the symbol's chars. This is a slowish operation because it
1431     /// requires locking the symbol interner.
1432     pub fn with<F: FnOnce(&str) -> R, R>(self, f: F) -> R {
1433         with_interner(|interner| f(interner.get(self)))
1434     }
1435
1436     /// Convert to a `SymbolStr`. This is a slowish operation because it
1437     /// requires locking the symbol interner.
1438     pub fn as_str(self) -> SymbolStr {
1439         with_interner(|interner| unsafe {
1440             SymbolStr { string: std::mem::transmute::<&str, &str>(interner.get(self)) }
1441         })
1442     }
1443
1444     pub fn as_u32(self) -> u32 {
1445         self.0.as_u32()
1446     }
1447
1448     /// This method is supposed to be used in error messages, so it's expected to be
1449     /// identical to printing the original identifier token written in source code
1450     /// (`token_to_string`, `Ident::to_string`), except that symbols don't keep the rawness flag
1451     /// or edition, so we have to guess the rawness using the global edition.
1452     pub fn to_ident_string(self) -> String {
1453         Ident::with_dummy_span(self).to_string()
1454     }
1455 }
1456
1457 impl fmt::Debug for Symbol {
1458     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1459         self.with(|str| fmt::Debug::fmt(&str, f))
1460     }
1461 }
1462
1463 impl fmt::Display for Symbol {
1464     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1465         self.with(|str| fmt::Display::fmt(&str, f))
1466     }
1467 }
1468
1469 impl<S: Encoder> Encodable<S> for Symbol {
1470     fn encode(&self, s: &mut S) -> Result<(), S::Error> {
1471         self.with(|string| s.emit_str(string))
1472     }
1473 }
1474
1475 impl<D: Decoder> Decodable<D> for Symbol {
1476     #[inline]
1477     fn decode(d: &mut D) -> Result<Symbol, D::Error> {
1478         Ok(Symbol::intern(&d.read_str()?))
1479     }
1480 }
1481
1482 impl<CTX> HashStable<CTX> for Symbol {
1483     #[inline]
1484     fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
1485         self.as_str().hash_stable(hcx, hasher);
1486     }
1487 }
1488
1489 impl<CTX> ToStableHashKey<CTX> for Symbol {
1490     type KeyType = SymbolStr;
1491
1492     #[inline]
1493     fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr {
1494         self.as_str()
1495     }
1496 }
1497
1498 // The `&'static str`s in this type actually point into the arena.
1499 //
1500 // The `FxHashMap`+`Vec` pair could be replaced by `FxIndexSet`, but #75278
1501 // found that to regress performance up to 2% in some cases. This might be
1502 // revisited after further improvements to `indexmap`.
1503 #[derive(Default)]
1504 pub struct Interner {
1505     arena: DroplessArena,
1506     names: FxHashMap<&'static str, Symbol>,
1507     strings: Vec<&'static str>,
1508 }
1509
1510 impl Interner {
1511     fn prefill(init: &[&'static str]) -> Self {
1512         Interner {
1513             strings: init.into(),
1514             names: init.iter().copied().zip((0..).map(Symbol::new)).collect(),
1515             ..Default::default()
1516         }
1517     }
1518
1519     #[inline]
1520     pub fn intern(&mut self, string: &str) -> Symbol {
1521         if let Some(&name) = self.names.get(string) {
1522             return name;
1523         }
1524
1525         let name = Symbol::new(self.strings.len() as u32);
1526
1527         // `from_utf8_unchecked` is safe since we just allocated a `&str` which is known to be
1528         // UTF-8.
1529         let string: &str =
1530             unsafe { str::from_utf8_unchecked(self.arena.alloc_slice(string.as_bytes())) };
1531         // It is safe to extend the arena allocation to `'static` because we only access
1532         // these while the arena is still alive.
1533         let string: &'static str = unsafe { &*(string as *const str) };
1534         self.strings.push(string);
1535         self.names.insert(string, name);
1536         name
1537     }
1538
1539     // Get the symbol as a string. `Symbol::as_str()` should be used in
1540     // preference to this function.
1541     pub fn get(&self, symbol: Symbol) -> &str {
1542         self.strings[symbol.0.as_usize()]
1543     }
1544 }
1545
1546 // This module has a very short name because it's used a lot.
1547 /// This module contains all the defined keyword `Symbol`s.
1548 ///
1549 /// Given that `kw` is imported, use them like `kw::keyword_name`.
1550 /// For example `kw::Loop` or `kw::Break`.
1551 pub mod kw {
1552     use super::Symbol;
1553     keywords!();
1554 }
1555
1556 // This module has a very short name because it's used a lot.
1557 /// This module contains all the defined non-keyword `Symbol`s.
1558 ///
1559 /// Given that `sym` is imported, use them like `sym::symbol_name`.
1560 /// For example `sym::rustfmt` or `sym::u8`.
1561 #[allow(rustc::default_hash_types)]
1562 pub mod sym {
1563     use super::Symbol;
1564     use std::convert::TryInto;
1565
1566     define_symbols!();
1567
1568     // Used from a macro in `librustc_feature/accepted.rs`
1569     pub use super::kw::MacroRules as macro_rules;
1570
1571     // Get the symbol for an integer. The first few non-negative integers each
1572     // have a static symbol and therefore are fast.
1573     pub fn integer<N: TryInto<usize> + Copy + ToString>(n: N) -> Symbol {
1574         if let Result::Ok(idx) = n.try_into() {
1575             if let Option::Some(&sym_) = digits_array.get(idx) {
1576                 return sym_;
1577             }
1578         }
1579         Symbol::intern(&n.to_string())
1580     }
1581 }
1582
1583 impl Symbol {
1584     fn is_used_keyword_2018(self) -> bool {
1585         self >= kw::Async && self <= kw::Dyn
1586     }
1587
1588     fn is_unused_keyword_2018(self) -> bool {
1589         self == kw::Try
1590     }
1591
1592     /// A keyword or reserved identifier that can be used as a path segment.
1593     pub fn is_path_segment_keyword(self) -> bool {
1594         self == kw::Super
1595             || self == kw::SelfLower
1596             || self == kw::SelfUpper
1597             || self == kw::Crate
1598             || self == kw::PathRoot
1599             || self == kw::DollarCrate
1600     }
1601
1602     /// Returns `true` if the symbol is `true` or `false`.
1603     pub fn is_bool_lit(self) -> bool {
1604         self == kw::True || self == kw::False
1605     }
1606
1607     /// This symbol can be a raw identifier.
1608     pub fn can_be_raw(self) -> bool {
1609         self != kw::Invalid && self != kw::Underscore && !self.is_path_segment_keyword()
1610     }
1611 }
1612
1613 impl Ident {
1614     // Returns `true` for reserved identifiers used internally for elided lifetimes,
1615     // unnamed method parameters, crate root module, error recovery etc.
1616     pub fn is_special(self) -> bool {
1617         self.name <= kw::Underscore
1618     }
1619
1620     /// Returns `true` if the token is a keyword used in the language.
1621     pub fn is_used_keyword(self) -> bool {
1622         // Note: `span.edition()` is relatively expensive, don't call it unless necessary.
1623         self.name >= kw::As && self.name <= kw::While
1624             || self.name.is_used_keyword_2018() && self.span.rust_2018()
1625     }
1626
1627     /// Returns `true` if the token is a keyword reserved for possible future use.
1628     pub fn is_unused_keyword(self) -> bool {
1629         // Note: `span.edition()` is relatively expensive, don't call it unless necessary.
1630         self.name >= kw::Abstract && self.name <= kw::Yield
1631             || self.name.is_unused_keyword_2018() && self.span.rust_2018()
1632     }
1633
1634     /// Returns `true` if the token is either a special identifier or a keyword.
1635     pub fn is_reserved(self) -> bool {
1636         self.is_special() || self.is_used_keyword() || self.is_unused_keyword()
1637     }
1638
1639     /// A keyword or reserved identifier that can be used as a path segment.
1640     pub fn is_path_segment_keyword(self) -> bool {
1641         self.name.is_path_segment_keyword()
1642     }
1643
1644     /// We see this identifier in a normal identifier position, like variable name or a type.
1645     /// How was it written originally? Did it use the raw form? Let's try to guess.
1646     pub fn is_raw_guess(self) -> bool {
1647         self.name.can_be_raw() && self.is_reserved()
1648     }
1649 }
1650
1651 #[inline]
1652 fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
1653     SESSION_GLOBALS.with(|session_globals| f(&mut *session_globals.symbol_interner.lock()))
1654 }
1655
1656 /// An alternative to `Symbol`, useful when the chars within the symbol need to
1657 /// be accessed. It deliberately has limited functionality and should only be
1658 /// used for temporary values.
1659 ///
1660 /// Because the interner outlives any thread which uses this type, we can
1661 /// safely treat `string` which points to interner data, as an immortal string,
1662 /// as long as this type never crosses between threads.
1663 //
1664 // FIXME: ensure that the interner outlives any thread which uses `SymbolStr`,
1665 // by creating a new thread right after constructing the interner.
1666 #[derive(Clone, Eq, PartialOrd, Ord)]
1667 pub struct SymbolStr {
1668     string: &'static str,
1669 }
1670
1671 // This impl allows a `SymbolStr` to be directly equated with a `String` or
1672 // `&str`.
1673 impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr {
1674     fn eq(&self, other: &T) -> bool {
1675         self.string == other.deref()
1676     }
1677 }
1678
1679 impl !Send for SymbolStr {}
1680 impl !Sync for SymbolStr {}
1681
1682 /// This impl means that if `ss` is a `SymbolStr`:
1683 /// - `*ss` is a `str`;
1684 /// - `&*ss` is a `&str` (and `match &*ss { ... }` is a common pattern).
1685 /// - `&ss as &str` is a `&str`, which means that `&ss` can be passed to a
1686 ///   function expecting a `&str`.
1687 impl std::ops::Deref for SymbolStr {
1688     type Target = str;
1689     #[inline]
1690     fn deref(&self) -> &str {
1691         self.string
1692     }
1693 }
1694
1695 impl fmt::Debug for SymbolStr {
1696     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1697         fmt::Debug::fmt(self.string, f)
1698     }
1699 }
1700
1701 impl fmt::Display for SymbolStr {
1702     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1703         fmt::Display::fmt(self.string, f)
1704     }
1705 }
1706
1707 impl<CTX> HashStable<CTX> for SymbolStr {
1708     #[inline]
1709     fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
1710         self.string.hash_stable(hcx, hasher)
1711     }
1712 }
1713
1714 impl<CTX> ToStableHashKey<CTX> for SymbolStr {
1715     type KeyType = SymbolStr;
1716
1717     #[inline]
1718     fn to_stable_hash_key(&self, _: &CTX) -> SymbolStr {
1719         self.clone()
1720     }
1721 }