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 proc_dash_macro = "proc-macro",
89 aapcs_dash_unwind = "aapcs-unwind",
90 avr_dash_interrupt = "avr-interrupt",
91 avr_dash_non_dash_blocking_dash_interrupt = "avr-non-blocking-interrupt",
92 C_dash_cmse_dash_nonsecure_dash_call = "C-cmse-nonsecure-call",
93 C_dash_cmse_dash_nonsecure_dash_entry = "C-cmse-nonsecure-entry",
94 C_dash_unwind = "C-unwind",
95 cdecl_dash_unwind = "cdecl-unwind",
96 fastcall_dash_unwind = "fastcall-unwind",
97 msp430_dash_interrupt = "msp430-interrupt",
98 ptx_dash_kernel = "ptx-kernel",
99 riscv_dash_interrupt_dash_m = "riscv-interrupt-m",
100 riscv_dash_interrupt_dash_s = "riscv-interrupt-s",
101 rust_dash_call = "rust-call",
102 rust_dash_cold = "rust-cold",
103 rust_dash_intrinsic = "rust-intrinsic",
104 stdcall_dash_unwind = "stdcall-unwind",
105 system_dash_unwind = "system-unwind",
106 sysv64_dash_unwind = "sysv64-unwind",
107 thiscall_dash_unwind = "thiscall-unwind",
108 vectorcall_dash_unwind = "vectorcall-unwind",
109 win64_dash_unwind = "win64-unwind",
110 x86_dash_interrupt = "x86-interrupt",
111
112 @PLAIN:
113 __ra_fixup,
114 aapcs,
115 add_assign,
116 add,
117 alias,
118 align_offset,
119 align,
120 all,
121 alloc_layout,
122 alloc,
123 allow_internal_unsafe,
124 allow,
125 any,
126 as_str,
127 asm,
128 assert,
129 attributes,
130 begin_panic,
131 bench,
132 bitand_assign,
133 bitand,
134 bitor_assign,
135 bitor,
136 bitxor_assign,
137 bitxor,
138 bool,
139 bootstrap,
140 box_free,
141 Box,
142 boxed,
143 branch,
144 Break,
145 c_void,
146 C,
147 call_mut,
148 call_once,
149 async_call_once,
150 async_call_mut,
151 async_call,
152 call,
153 cdecl,
154 Center,
155 cfg_accessible,
156 cfg_attr,
157 cfg_eval,
158 cfg,
159 char,
160 clone,
161 Clone,
162 coerce_unsized,
163 column,
164 completion,
165 compile_error,
166 concat_bytes,
167 concat_idents,
168 concat,
169 const_format_args,
170 const_panic_fmt,
171 const_param_ty,
172 Context,
173 Continue,
174 convert,
175 copy,
176 Copy,
177 core_panic,
178 core,
179 coroutine_state,
180 coroutine,
181 count,
182 crate_type,
183 CStr,
184 debug_assertions,
185 Debug,
186 default,
187 Default,
188 deprecated,
189 deref_mut,
190 deref_target,
191 deref,
192 derive_const,
193 derive,
194 discriminant_kind,
195 discriminant_type,
196 dispatch_from_dyn,destruct,
197 div_assign,
198 div,
199 doc,
200 drop_in_place,
201 drop,
202 dyn_metadata,
203 efiapi,
204 eh_catch_typeinfo,
205 eh_personality,
206 env,
207 eq,
208 Eq,
209 Err,
210 exchange_malloc,
211 exhaustive_patterns,
212 export_name,
213 f128,
214 f16,
215 f32,
216 f64,
217 fastcall,
218 feature,
219 file,
220 filter_map,
221 fmt,
222 fn_mut,
223 fn_once_output,
224 fn_once,
225 async_fn_once,
226 async_fn_mut,
227 async_fn,
228 fn_ptr_addr,
229 fn_ptr_trait,
230 format_alignment,
231 format_args_nl,
232 format_args,
233 format_argument,
234 format_arguments,
235 format_count,
236 format_placeholder,
237 format_unsafe_arg,
238 format,
239 freeze,
240 from,
241 From,
242 FromStr,
243 from_str,
244 from_output,
245 from_residual,
246 from_usize,
247 from_yeet,
248 fundamental,
249 future_trait,
250 future,
251 future_output,
252 Future,
253 ge,
254 generic_associated_type_extended,
255 get_context,
256 global_allocator,
257 global_asm,
258 gt,
259 Hash,
260 hidden,
261 html_root_url,
262 i128,
263 i16,
264 i32,
265 i64,
266 i8,
267 ignore,
268 Implied,
269 include_bytes,
270 include_str,
271 include,
272 index_mut,
273 index,
274 Index,
275 into,
276 Into,
277 into_future,
278 into_iter,
279 IntoFuture,
280 IntoIter,
281 IntoIterator,
282 is_empty,
283 Is,
284 isize,
285 Item,
286 iter_mut,
287 iter,
288 Iterator,
289 iterator,
290 keyword,
291 lang,
292 le,
293 Left,
294 len,
295 line,
296 llvm_asm,
297 local_inner_macros,
298 log_syntax,
299 lt,
300 macro_export,
301 macro_rules,
302 macro_use,
303 main,
304 manually_drop,
305 may_dangle,
306 maybe_uninit,
307 metadata_type,
308 min_exhaustive_patterns,
309 miri,
310 missing,
311 module_path,
312 mul_assign,
313 mul,
314 naked_asm,
315 ne,
316 neg,
317 Neg,
318 new_binary,
319 new_debug,
320 new_display,
321 new_lower_exp,
322 new_lower_hex,
323 new_octal,
324 new_pointer,
325 new_unchecked,
326 new_upper_exp,
327 new_upper_hex,
328 new_v1_formatted,
329 new,
330 next,
331 no_core,
332 no_mangle,
333 no_std,
334 non_exhaustive,
335 none,
336 None,
337 not,
338 Not,
339 notable_trait,
340 Ok,
341 opaque,
342 ops,
343 option_env,
344 option,
345 Option,
346 Ord,
347 Ordering,
348 Output,
349 CallRefFuture,
350 CallOnceFuture,
351 owned_box,
352 packed,
353 panic_2015,
354 panic_2021,
355 panic_bounds_check,
356 panic_cannot_unwind,
357 panic_display,
358 panic_fmt,
359 panic_impl,
360 panic_info,
361 panic_location,
362 panic_misaligned_pointer_dereference,
363 panic_nounwind,
364 panic_null_pointer_dereference,
365 panic,
366 Param,
367 parse,
368 partial_ord,
369 PartialEq,
370 PartialOrd,
371 CoercePointee,
372 path,
373 Pending,
374 phantom_data,
375 pieces,
376 pin,
377 pointee_trait,
378 pointer_like,
379 poll,
380 Poll,
381 prelude_import,
382 prelude,
383 proc_macro_attribute,
384 proc_macro_derive,
385 proc_macro,
386 quote,
387 range_inclusive_new,
388 Range,
389 RangeFrom,
390 RangeFull,
391 RangeInclusive,
392 RangeTo,
393 RangeToInclusive,
394 Ready,
395 receiver,
396 receiver_target,
397 recursion_limit,
398 register_attr,
399 register_tool,
400 rem_assign,
401 rem,
402 repr,
403 result,
404 Result,
405 ResumeTy,
406 Right,
407 rust_2015,
408 rust_2018,
409 rust_2021,
410 rust_2024,
411 rust_analyzer,
412 Rust,
413 rustc_allocator_zeroed,
414 rustc_allocator,
415 rustc_allow_incoherent_impl,
416 rustc_builtin_macro,
417 rustc_coherence_is_core,
418 rustc_const_panic_str,
419 rustc_deallocator,
420 rustc_deprecated_safe_2024,
421 rustc_has_incoherent_inherent_impls,
422 rustc_intrinsic_must_be_overridden,
423 rustc_intrinsic,
424 rustc_layout_scalar_valid_range_end,
425 rustc_layout_scalar_valid_range_start,
426 rustc_legacy_const_generics,
427 rustc_macro_transparency,
428 rustc_paren_sugar,
429 rustc_reallocator,
430 rustc_reservation_impl,
431 rustc_safe_intrinsic,
432 rustc_skip_array_during_method_dispatch,
433 rustc_skip_during_method_dispatch,
434 semitransparent,
435 shl_assign,
436 shl,
437 shr_assign,
438 shr,
439 simd,
440 sized,
441 skip,
442 slice_len_fn,
443 Some,
444 start,
445 std_panic,
446 std,
447 stdcall,
448 str,
449 string,
450 String,
451 stringify,
452 structural_peq,
453 structural_teq,
454 sub_assign,
455 sub,
456 sync,
457 system,
458 sysv64,
459 Target,
460 target_feature,
461 enable,
462 termination,
463 test_case,
464 test,
465 then,
466 thiscall,
467 to_string,
468 trace_macros,
469 transmute_opts,
470 transmute_trait,
471 transparent,
472 try_into,
473 Try,
474 TryFrom,
475 try_from,
476 tuple_trait,
477 u128,
478 u16,
479 u32,
480 u64,
481 u8,
482 unadjusted,
483 unknown,
484 Unknown,
485 unpin,
486 unreachable_2015,
487 unreachable_2021,
488 unreachable,
489 unsafe_cell,
490 unsafe_pinned,
491 unsize,
492 unstable,
493 usize,
494 v1,
495 va_list,
496 vectorcall,
497 wasm,
498 win64,
499 array,
500 boxed_slice,
501 completions,
502 ignore_flyimport,
503 ignore_flyimport_methods,
504 ignore_methods,
505 position,
506 flags,
507 precision,
508 width,
509}