intern/symbol/
symbols.rs

1//! Module defining all known symbols required by the rest of rust-analyzer.
2#![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        // The strings should be in `static`s so that symbol equality holds.
14        $(
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    trivial_clone,
165    Clone,
166    coerce_unsized,
167    column,
168    completion,
169    compile_error,
170    concat_bytes,
171    concat,
172    const_format_args,
173    const_panic_fmt,
174    const_param_ty,
175    Context,
176    Continue,
177    convert,
178    copy,
179    Copy,
180    core_panic,
181    core,
182    coroutine_state,
183    coroutine,
184    coroutine_return,
185    coroutine_yield,
186    count,
187    crate_type,
188    CStr,
189    debug_assertions,
190    Debug,
191    default,
192    Default,
193    deprecated,
194    deref_mut,
195    deref_target,
196    deref,
197    derive_const,
198    derive,
199    discriminant_kind,
200    discriminant_type,
201    dispatch_from_dyn,destruct,
202    div_assign,
203    div,
204    doc,
205    drop_in_place,
206    drop,
207    dyn_metadata,
208    efiapi,
209    eh_catch_typeinfo,
210    eh_personality,
211    env,
212    eq,
213    Eq,
214    Err,
215    exchange_malloc,
216    exhaustive_patterns,
217    export_name,
218    f128,
219    f16,
220    f32,
221    f64,
222    fastcall,
223    feature,
224    file,
225    filter_map,
226    fmt,
227    fn_mut,
228    fn_once_output,
229    fn_once,
230    async_fn_once,
231    async_fn_once_output,
232    async_fn_mut,
233    async_fn,
234    call_ref_future,
235    call_once_future,
236    fn_ptr_addr,
237    fn_ptr_trait,
238    format_alignment,
239    format_args_nl,
240    format_args,
241    format_argument,
242    format_arguments,
243    format_count,
244    format_placeholder,
245    format_unsafe_arg,
246    format,
247    freeze,
248    from,
249    From,
250    FromStr,
251    from_str,
252    from_output,
253    from_residual,
254    from_usize,
255    from_yeet,
256    fundamental,
257    future_trait,
258    future,
259    future_output,
260    Future,
261    ge,
262    generic_associated_type_extended,
263    get_context,
264    global_allocator,
265    global_asm,
266    gt,
267    Hash,
268    hidden,
269    html_root_url,
270    i128,
271    i16,
272    i32,
273    i64,
274    i8,
275    ignore,
276    Implied,
277    include_bytes,
278    include_str,
279    include,
280    index_mut,
281    index,
282    Index,
283    into,
284    Into,
285    into_future,
286    into_iter,
287    IntoFuture,
288    IntoIter,
289    IntoIterator,
290    is_empty,
291    Is,
292    isize,
293    Item,
294    iter_mut,
295    iter,
296    Iterator,
297    iterator,
298    keyword,
299    lang,
300    le,
301    Left,
302    len,
303    line,
304    llvm_asm,
305    local_inner_macros,
306    log_syntax,
307    lt,
308    macro_export,
309    macro_rules,
310    macro_use,
311    main,
312    manually_drop,
313    may_dangle,
314    maybe_uninit,
315    metadata_type,
316    min_exhaustive_patterns,
317    miri,
318    missing,
319    module_path,
320    mul_assign,
321    mul,
322    naked_asm,
323    ne,
324    neg,
325    Neg,
326    new_binary,
327    new_debug,
328    new_display,
329    new_lower_exp,
330    new_lower_hex,
331    new_octal,
332    new_pointer,
333    new_unchecked,
334    new_upper_exp,
335    new_upper_hex,
336    new_v1_formatted,
337    new,
338    next,
339    no_core,
340    no_mangle,
341    no_std,
342    non_exhaustive,
343    none,
344    None,
345    not,
346    Not,
347    notable_trait,
348    Ok,
349    opaque,
350    ops,
351    option_env,
352    option,
353    Option,
354    Ord,
355    Ordering,
356    Output,
357    CallRefFuture,
358    CallOnceFuture,
359    owned_box,
360    packed,
361    panic_2015,
362    panic_2021,
363    panic_bounds_check,
364    panic_cannot_unwind,
365    panic_display,
366    panic_fmt,
367    panic_impl,
368    panic_info,
369    panic_location,
370    panic_misaligned_pointer_dereference,
371    panic_nounwind,
372    panic_null_pointer_dereference,
373    panic,
374    Param,
375    parse,
376    partial_ord,
377    PartialEq,
378    PartialOrd,
379    CoercePointee,
380    path,
381    Pending,
382    phantom_data,
383    pieces,
384    pin,
385    pointee_trait,
386    pointer_like,
387    poll,
388    Poll,
389    prelude_import,
390    prelude,
391    proc_macro_attribute,
392    proc_macro_derive,
393    proc_macro,
394    quote,
395    range_inclusive_new,
396    Range,
397    RangeFrom,
398    RangeFull,
399    RangeInclusive,
400    RangeTo,
401    RangeToInclusive,
402    Ready,
403    receiver,
404    receiver_target,
405    recursion_limit,
406    register_attr,
407    register_tool,
408    rem_assign,
409    rem,
410    repr,
411    result,
412    Result,
413    ResumeTy,
414    Right,
415    rust_2015,
416    rust_2018,
417    rust_2021,
418    rust_2024,
419    rust_analyzer,
420    Rust,
421    rustc_allocator_zeroed,
422    rustc_allocator,
423    rustc_allow_incoherent_impl,
424    rustc_builtin_macro,
425    rustc_coherence_is_core,
426    rustc_coinductive,
427    rustc_const_panic_str,
428    rustc_deallocator,
429    rustc_deprecated_safe_2024,
430    rustc_has_incoherent_inherent_impls,
431    rustc_intrinsic_must_be_overridden,
432    rustc_intrinsic,
433    rustc_layout_scalar_valid_range_end,
434    rustc_layout_scalar_valid_range_start,
435    rustc_legacy_const_generics,
436    rustc_macro_transparency,
437    rustc_paren_sugar,
438    rustc_reallocator,
439    rustc_reservation_impl,
440    rustc_safe_intrinsic,
441    rustc_skip_array_during_method_dispatch,
442    rustc_skip_during_method_dispatch,
443    rustc_force_inline,
444    semitransparent,
445    shl_assign,
446    shl,
447    shr_assign,
448    shr,
449    simd,
450    sized,
451    meta_sized,
452    pointee_sized,
453    skip,
454    slice_len_fn,
455    Some,
456    start,
457    std_panic,
458    std,
459    stdcall,
460    str,
461    string,
462    String,
463    stringify,
464    structural_peq,
465    structural_teq,
466    sub_assign,
467    sub,
468    sync,
469    system,
470    sysv64,
471    Target,
472    target_feature,
473    enable,
474    termination,
475    test_case,
476    test,
477    then,
478    thiscall,
479    to_string,
480    trace_macros,
481    transmute_opts,
482    transmute_trait,
483    transparent,
484    try_into,
485    Try,
486    TryFrom,
487    try_from,
488    tuple_trait,
489    u128,
490    u16,
491    u32,
492    u64,
493    u8,
494    unadjusted,
495    unknown,
496    Unknown,
497    unpin,
498    unreachable_2015,
499    unreachable_2021,
500    unreachable,
501    unsafe_cell,
502    unsafe_pinned,
503    unsize,
504    unstable,
505    usize,
506    v1,
507    va_list,
508    vectorcall,
509    wasm,
510    win64,
511    args,
512    array,
513    boxed_slice,
514    completions,
515    ignore_flyimport,
516    ignore_flyimport_methods,
517    ignore_methods,
518    position,
519    flags,
520    precision,
521    width,
522    never_type_fallback,
523    specialization,
524    min_specialization,
525    arbitrary_self_types,
526    arbitrary_self_types_pointers,
527    supertrait_item_shadowing,
528    define_opaque,
529}