Skip to main content

luaur_analysis/functions/
attach_magic_function.rs

1use crate::functions::get_mutable_constraint::get_mutable_constraint;
2use crate::functions::get_mutable_txn_log::get_mutable_pending_type;
3use crate::functions::get_mutable_txn_log_alt_c::get_mutable_pending_type_pack;
4use crate::functions::get_mutable_type::get_mutable_type_id;
5use crate::functions::get_mutable_type_function_runtime::get_mutable_type_function_singleton_type;
6use crate::functions::get_mutable_type_function_runtime_alt_f::get_mutable_type_function_type_pack_id;
7use crate::functions::get_mutable_type_function_runtime_alt_g::get_mutable_type_function_type_id;
8use crate::functions::get_mutable_type_pack::get_mutable_type_pack_id;
9use crate::functions::get_mutable_type_utils::get_mutable_optional_ty;
10use crate::records::function_type::FunctionType;
11use crate::records::magic_function::MagicFunction;
12use crate::type_aliases::type_id::TypeId;
13use alloc::sync::Arc;
14use luaur_common::macros::luau_assert::LUAU_ASSERT;
15
16pub fn attach_magic_function(ty: TypeId, magic: Arc<MagicFunction>) {
17    unsafe {
18        let ftv = get_mutable_type_id::<FunctionType>(ty);
19        if !ftv.is_null() {
20            (*ftv).magic = Some(magic);
21        } else {
22            LUAU_ASSERT!(false);
23        }
24    }
25}
26
27// Pinned overload name advertised by the dependency cards.
28#[allow(unused_imports, non_snake_case)]
29pub use attach_magic_function as attach_magic_function_TypeId_Arc_MagicFunction;