luaur_analysis/records/constraint_set.rs
1//! Generated skeleton item.
2//! Node: `cxx:Record:Luau.Analysis:Analysis/include/Luau/ConstraintSet.h:14:constraint_set`
3//! Source: `Analysis/include/Luau/ConstraintSet.h`
4//! Graph edges:
5//! - declared_by: source_file Analysis/include/Luau/ConstraintSet.h
6//! - source_includes:
7//! - includes -> source_file Analysis/include/Luau/Constraint.h
8//! - includes -> source_file Analysis/include/Luau/TypeIds.h
9//! - includes -> source_file Analysis/include/Luau/Error.h
10//! - incoming:
11//! - declares <- source_file Analysis/include/Luau/ConstraintSet.h
12//! - type_ref <- record ConstraintGenerator (Analysis/include/Luau/ConstraintGenerator.h)
13//! - type_ref <- record ConstraintSolver (Analysis/include/Luau/ConstraintSolver.h)
14//! - type_ref <- method ConstraintGenerator::run (Analysis/src/ConstraintGenerator.cpp)
15//! - type_ref <- method ConstraintGenerator::runOnFragment (Analysis/src/ConstraintGenerator.cpp)
16//! - type_ref <- method ConstraintSolver::ConstraintSolver (Analysis/src/ConstraintSolver.cpp)
17//! - type_ref <- function check (Analysis/src/Frontend.cpp)
18//! - outgoing:
19//! - type_ref -> record Scope (Analysis/include/Luau/Scope.h)
20//! - type_ref -> type_alias ConstraintPtr (Analysis/include/Luau/Constraint.h)
21//! - type_ref -> record TypeIds (Analysis/include/Luau/TypeIds.h)
22//! - type_ref -> record DenseHashMap (Common/include/Luau/DenseHash.h)
23//! - type_ref -> type_alias TypeId (Analysis/include/Luau/TypeFwd.h)
24//! - type_ref -> record TypeError (Analysis/include/Luau/Error.h)
25//! - translates_to -> rust_item ConstraintSet
26
27extern crate alloc;
28
29use alloc::vec::Vec;
30use luaur_common::records::dense_hash_map::DenseHashMap;
31
32use crate::records::scope::Scope;
33use crate::records::type_error::TypeError;
34use crate::records::type_ids::TypeIds;
35use crate::type_aliases::constraint_ptr::ConstraintPtr;
36use crate::type_aliases::type_id::TypeId;
37
38#[derive(Debug)]
39pub struct ConstraintSet {
40 pub root_scope: *mut Scope,
41 pub constraints: Vec<ConstraintPtr>,
42 // The set of all free types created during constraint generation
43 pub free_types: TypeIds,
44 // Map a function's signature scope back to its signature type. Once we've
45 // dispatched all of the constraints pertaining to a particular free type,
46 // we use this mapping to generalize that free type.
47 pub scope_to_function: DenseHashMap<*mut Scope, TypeId>,
48 // It is pretty uncommon for constraint generation to itself produce errors, but it can happen.
49 pub errors: Vec<TypeError>,
50}