1#![allow(non_upper_case_globals)]
3
4use std::hash::{BuildHasher, BuildHasherDefault};
5
6use dashmap::{DashMap, SharedValue};
7use rustc_hash::FxHasher;
8
9use crate::{Symbol, symbol::TaggedArcPtr};
10
11macro_rules! define_symbols {
12 (@WITH_NAME: $($alias:ident = $value:literal,)* @PLAIN: $($name:ident,)*) => {
13 $(
15 pub const $name: Symbol = {
16 static SYMBOL_STR: &str = stringify!($name);
17 Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) }
18 };
19 )*
20 $(
21 pub const $alias: Symbol = {
22 static SYMBOL_STR: &str = $value;
23 Symbol { repr: TaggedArcPtr::non_arc(&SYMBOL_STR) }
24 };
25 )*
26
27
28 pub(super) fn prefill() -> DashMap<Symbol, (), BuildHasherDefault<FxHasher>> {
29 let mut dashmap_ = <DashMap<Symbol, (), BuildHasherDefault<FxHasher>>>::with_hasher(BuildHasherDefault::default());
30
31 let hasher_ = dashmap_.hasher().clone();
32 let hash_one = |it_: &str| hasher_.hash_one(it_);
33 {
34 $(
35 let s = stringify!($name);
36 let hash_ = hash_one(s);
37 let shard_idx_ = dashmap_.determine_shard(hash_ as usize);
38 dashmap_.shards_mut()[shard_idx_].get_mut().insert(hash_, ($name, SharedValue::new(())), |(x, _)| hash_one(x.as_str()));
39 )*
40 $(
41 let s = $value;
42 let hash_ = hash_one(s);
43 let shard_idx_ = dashmap_.determine_shard(hash_ as usize);
44 dashmap_.shards_mut()[shard_idx_].get_mut().insert(hash_, ($alias, SharedValue::new(())), |(x, _)| hash_one(x.as_str()));
45 )*
46 }
47 dashmap_
48 }
49 };
50}
51define_symbols! {
52 @WITH_NAME:
53
54 dotdotdot = "...",
55 INTEGER_0 = "0",
56 INTEGER_1 = "1",
57 INTEGER_2 = "2",
58 INTEGER_3 = "3",
59 INTEGER_4 = "4",
60 INTEGER_5 = "5",
61 INTEGER_6 = "6",
62 INTEGER_7 = "7",
63 INTEGER_8 = "8",
64 INTEGER_9 = "9",
65 INTEGER_10 = "10",
66 INTEGER_11 = "11",
67 INTEGER_12 = "12",
68 INTEGER_13 = "13",
69 INTEGER_14 = "14",
70 INTEGER_15 = "15",
71 __empty = "",
72 unsafe_ = "unsafe",
73 in_ = "in",
74 super_ = "super",
75 self_ = "self",
76 Self_ = "Self",
77 tick_static = "'static",
78 tick_underscore = "'_",
79 dollar_crate = "$crate",
80 MISSING_NAME = "[missing name]",
81 fn_ = "fn",
82 crate_ = "crate",
83 underscore = "_",
84 true_ = "true",
85 false_ = "false",
86 let_ = "let",
87 const_ = "const",
88 kw_impl = "impl",
89 proc_dash_macro = "proc-macro",
90 aapcs_dash_unwind = "aapcs-unwind",
91 avr_dash_interrupt = "avr-interrupt",
92 avr_dash_non_dash_blocking_dash_interrupt = "avr-non-blocking-interrupt",
93 C_dash_cmse_dash_nonsecure_dash_call = "C-cmse-nonsecure-call",
94 C_dash_cmse_dash_nonsecure_dash_entry = "C-cmse-nonsecure-entry",
95 C_dash_unwind = "C-unwind",
96 cdecl_dash_unwind = "cdecl-unwind",
97 fastcall_dash_unwind = "fastcall-unwind",
98 msp430_dash_interrupt = "msp430-interrupt",
99 ptx_dash_kernel = "ptx-kernel",
100 riscv_dash_interrupt_dash_m = "riscv-interrupt-m",
101 riscv_dash_interrupt_dash_s = "riscv-interrupt-s",
102 rust_dash_call = "rust-call",
103 rust_dash_cold = "rust-cold",
104 rust_dash_intrinsic = "rust-intrinsic",
105 stdcall_dash_unwind = "stdcall-unwind",
106 system_dash_unwind = "system-unwind",
107 sysv64_dash_unwind = "sysv64-unwind",
108 thiscall_dash_unwind = "thiscall-unwind",
109 vectorcall_dash_unwind = "vectorcall-unwind",
110 win64_dash_unwind = "win64-unwind",
111 x86_dash_interrupt = "x86-interrupt",
112
113 @PLAIN:
114 __ra_fixup,
115 aapcs,
116 add_assign,
117 add,
118 alias,
119 align_offset,
120 align,
121 all,
122 alloc_layout,
123 alloc,
124 allow_internal_unsafe,
125 allow,
126 any,
127 as_str,
128 asm,
129 assert,
130 attr,
131 attributes,
132 begin_panic,
133 bench,
134 bitand_assign,
135 bitand,
136 bitor_assign,
137 bitor,
138 bitxor_assign,
139 bitxor,
140 bool,
141 bootstrap,
142 box_free,
143 Box,
144 boxed,
145 branch,
146 Break,
147 c_void,
148 C,
149 call_mut,
150 call_once,
151 async_call_once,
152 async_call_mut,
153 async_call,
154 call,
155 cdecl,
156 Center,
157 cfg_accessible,
158 cfg_attr,
159 cfg_eval,
160 cfg,
161 cfg_select,
162 char,
163 clone,
164 Clone,
165 coerce_unsized,
166 column,
167 completion,
168 compile_error,
169 concat_bytes,
170 concat,
171 const_format_args,
172 const_panic_fmt,
173 const_param_ty,
174 Context,
175 Continue,
176 convert,
177 copy,
178 Copy,
179 core_panic,
180 core,
181 coroutine_state,
182 coroutine,
183 coroutine_return,
184 coroutine_yield,
185 count,
186 crate_type,
187 CStr,
188 debug_assertions,
189 Debug,
190 default,
191 Default,
192 deprecated,
193 deref_mut,
194 deref_target,
195 deref,
196 derive_const,
197 derive,
198 discriminant_kind,
199 discriminant_type,
200 dispatch_from_dyn,destruct,
201 div_assign,
202 div,
203 doc,
204 drop_in_place,
205 drop,
206 dyn_metadata,
207 efiapi,
208 eh_catch_typeinfo,
209 eh_personality,
210 env,
211 eq,
212 Eq,
213 Err,
214 exchange_malloc,
215 exhaustive_patterns,
216 export_name,
217 f128,
218 f16,
219 f32,
220 f64,
221 fastcall,
222 feature,
223 file,
224 filter_map,
225 fmt,
226 fn_mut,
227 fn_once_output,
228 fn_once,
229 async_fn_once,
230 async_fn_once_output,
231 async_fn_mut,
232 async_fn,
233 call_ref_future,
234 call_once_future,
235 fn_ptr_addr,
236 fn_ptr_trait,
237 format_alignment,
238 format_args_nl,
239 format_args,
240 format_argument,
241 format_arguments,
242 format_count,
243 format_placeholder,
244 format_unsafe_arg,
245 format,
246 freeze,
247 from,
248 From,
249 FromStr,
250 from_str,
251 from_output,
252 from_residual,
253 from_usize,
254 from_yeet,
255 fundamental,
256 future_trait,
257 future,
258 future_output,
259 Future,
260 ge,
261 generic_associated_type_extended,
262 get_context,
263 global_allocator,
264 global_asm,
265 gt,
266 Hash,
267 hidden,
268 html_root_url,
269 i128,
270 i16,
271 i32,
272 i64,
273 i8,
274 ignore,
275 Implied,
276 include_bytes,
277 include_str,
278 include,
279 index_mut,
280 index,
281 Index,
282 into,
283 Into,
284 into_future,
285 into_iter,
286 IntoFuture,
287 IntoIter,
288 IntoIterator,
289 is_empty,
290 Is,
291 isize,
292 Item,
293 iter_mut,
294 iter,
295 Iterator,
296 iterator,
297 keyword,
298 lang,
299 le,
300 Left,
301 len,
302 line,
303 llvm_asm,
304 local_inner_macros,
305 log_syntax,
306 lt,
307 macro_export,
308 macro_rules,
309 macro_use,
310 main,
311 manually_drop,
312 may_dangle,
313 maybe_uninit,
314 metadata_type,
315 min_exhaustive_patterns,
316 miri,
317 missing,
318 module_path,
319 mul_assign,
320 mul,
321 naked_asm,
322 ne,
323 neg,
324 Neg,
325 new_binary,
326 new_debug,
327 new_display,
328 new_lower_exp,
329 new_lower_hex,
330 new_octal,
331 new_pointer,
332 new_unchecked,
333 new_upper_exp,
334 new_upper_hex,
335 new_v1_formatted,
336 new,
337 next,
338 no_core,
339 no_mangle,
340 no_std,
341 non_exhaustive,
342 none,
343 None,
344 not,
345 Not,
346 notable_trait,
347 Ok,
348 opaque,
349 ops,
350 option_env,
351 option,
352 Option,
353 Ord,
354 Ordering,
355 Output,
356 CallRefFuture,
357 CallOnceFuture,
358 owned_box,
359 packed,
360 panic_2015,
361 panic_2021,
362 panic_bounds_check,
363 panic_cannot_unwind,
364 panic_display,
365 panic_fmt,
366 panic_impl,
367 panic_info,
368 panic_location,
369 panic_misaligned_pointer_dereference,
370 panic_nounwind,
371 panic_null_pointer_dereference,
372 panic,
373 Param,
374 parse,
375 partial_ord,
376 PartialEq,
377 PartialOrd,
378 CoercePointee,
379 path,
380 Pending,
381 phantom_data,
382 pieces,
383 pin,
384 pointee_trait,
385 pointer_like,
386 poll,
387 Poll,
388 prelude_import,
389 prelude,
390 proc_macro_attribute,
391 proc_macro_derive,
392 proc_macro,
393 quote,
394 range_inclusive_new,
395 Range,
396 RangeFrom,
397 RangeFull,
398 RangeInclusive,
399 RangeTo,
400 RangeToInclusive,
401 Ready,
402 receiver,
403 receiver_target,
404 recursion_limit,
405 register_attr,
406 register_tool,
407 rem_assign,
408 rem,
409 repr,
410 result,
411 Result,
412 ResumeTy,
413 Right,
414 rust_2015,
415 rust_2018,
416 rust_2021,
417 rust_2024,
418 rust_analyzer,
419 Rust,
420 rustc_allocator_zeroed,
421 rustc_allocator,
422 rustc_allow_incoherent_impl,
423 rustc_builtin_macro,
424 rustc_coherence_is_core,
425 rustc_coinductive,
426 rustc_const_panic_str,
427 rustc_deallocator,
428 rustc_deprecated_safe_2024,
429 rustc_has_incoherent_inherent_impls,
430 rustc_intrinsic_must_be_overridden,
431 rustc_intrinsic,
432 rustc_layout_scalar_valid_range_end,
433 rustc_layout_scalar_valid_range_start,
434 rustc_legacy_const_generics,
435 rustc_macro_transparency,
436 rustc_paren_sugar,
437 rustc_reallocator,
438 rustc_reservation_impl,
439 rustc_safe_intrinsic,
440 rustc_skip_array_during_method_dispatch,
441 rustc_skip_during_method_dispatch,
442 rustc_force_inline,
443 semitransparent,
444 shl_assign,
445 shl,
446 shr_assign,
447 shr,
448 simd,
449 sized,
450 meta_sized,
451 pointee_sized,
452 skip,
453 slice_len_fn,
454 Some,
455 start,
456 std_panic,
457 std,
458 stdcall,
459 str,
460 string,
461 String,
462 stringify,
463 structural_peq,
464 structural_teq,
465 sub_assign,
466 sub,
467 sync,
468 system,
469 sysv64,
470 Target,
471 target_feature,
472 enable,
473 termination,
474 test_case,
475 test,
476 then,
477 thiscall,
478 to_string,
479 trace_macros,
480 transmute_opts,
481 transmute_trait,
482 transparent,
483 try_into,
484 Try,
485 TryFrom,
486 try_from,
487 tuple_trait,
488 u128,
489 u16,
490 u32,
491 u64,
492 u8,
493 unadjusted,
494 unknown,
495 Unknown,
496 unpin,
497 unreachable_2015,
498 unreachable_2021,
499 unreachable,
500 unsafe_cell,
501 unsafe_pinned,
502 unsize,
503 unstable,
504 usize,
505 v1,
506 va_list,
507 vectorcall,
508 wasm,
509 win64,
510 args,
511 array,
512 boxed_slice,
513 completions,
514 ignore_flyimport,
515 ignore_flyimport_methods,
516 ignore_methods,
517 position,
518 flags,
519 precision,
520 width,
521 never_type_fallback,
522 specialization,
523 min_specialization,
524 arbitrary_self_types,
525 arbitrary_self_types_pointers,
526 supertrait_item_shadowing,
527 define_opaque,
528}