Skip to main content

luaur_analysis/records/
inference.rs

1//! @interface-stub
2use crate::type_aliases::refinement_id_refinement::RefinementId;
3use crate::type_aliases::type_id::TypeId;
4
5#[derive(Debug, Clone)]
6pub struct Inference {
7    pub ty: TypeId,
8    pub refinement: RefinementId,
9}
10
11impl luaur_common::records::dense_hash_table::DenseDefault for Inference {
12    fn dense_default() -> Self {
13        Self {
14            ty: core::ptr::null(),
15            refinement: core::ptr::null_mut(),
16        }
17    }
18}
19
20impl Inference {
21    // C++: `Inference()` — `ty` default-initialized to nullptr, no refinement.
22    // (Analysis/include/Luau/ConstraintGenerator.h)
23    pub fn inference() -> Self {
24        Self {
25            ty: core::ptr::null(),
26            refinement: core::ptr::null_mut(),
27        }
28    }
29    // C++: `Inference(TypeId ty, RefinementId refinement = nullptr)`.
30    pub fn inference_type_id_refinement_id(ty: TypeId, refinement: RefinementId) -> Self {
31        Self { ty, refinement }
32    }
33}