luaur_analysis/functions/
clone_clone_alt_d.rs1use crate::functions::clone_clone_alt_b::with_clone_maps;
2use crate::records::binding::Binding;
3use crate::records::clone_state::CloneState;
4use crate::records::type_arena::TypeArena;
5use crate::records::type_cloner::TypeCloner;
6use crate::type_aliases::type_id::TypeId;
7use crate::type_aliases::type_pack_id::TypePackId;
8use std::collections::HashMap;
9
10pub fn clone(binding: &Binding, dest: &mut TypeArena, clone_state: &mut CloneState) -> Binding {
11 let builtin_types = clone_state.builtin_types;
12 with_clone_maps(
13 &mut clone_state.seen_types,
14 &mut clone_state.seen_type_packs,
15 |tys, tps| {
16 let mut cloner = TypeCloner {
17 arena: dest as *mut TypeArena,
18 builtin_types,
19 queue: alloc::vec::Vec::new(),
20 types: tys as *mut HashMap<TypeId, TypeId>,
21 packs: tps as *mut HashMap<TypePackId, TypePackId>,
22 force_ty: core::ptr::null(),
23 force_tp: core::ptr::null(),
24 steps: 0,
25 replacement_for_null_scope: core::ptr::null_mut(),
26 skip_lazy_type_clone: false,
27 };
28
29 Binding {
30 deprecated: binding.deprecated,
31 deprecated_suggestion: binding.deprecated_suggestion.clone(),
32 documentation_symbol: binding.documentation_symbol.clone(),
33 location: binding.location,
34 type_id: cloner.clone_type_id(binding.type_id),
35 }
36 },
37 )
38}