pub struct TracerSubtypeChecker<'a> { /* private fields */ }Expand description
Tracer-based subtype checker.
This provides a unified API for both fast boolean checks and detailed diagnostics
by using the SubtypeTracer trait to abstract the failure handling.
The checker maintains its own cycle detection and depth tracking to avoid
interfering with the main SubtypeChecker state.
Implementations§
Source§impl<'a> TracerSubtypeChecker<'a>
impl<'a> TracerSubtypeChecker<'a>
Sourcepub fn new(interner: &'a dyn TypeDatabase) -> Self
pub fn new(interner: &'a dyn TypeDatabase) -> Self
Create a new tracer-based subtype checker.
Sourcepub const fn with_strict_function_types(self, strict: bool) -> Self
pub const fn with_strict_function_types(self, strict: bool) -> Self
Set whether to use strict function types.
Sourcepub const fn with_allow_void_return(self, allow: bool) -> Self
pub const fn with_allow_void_return(self, allow: bool) -> Self
Set whether to allow void return type optimization.
Sourcepub const fn with_strict_null_checks(self, strict: bool) -> Self
pub const fn with_strict_null_checks(self, strict: bool) -> Self
Set strict null checks mode.
Sourcepub fn check_subtype_with_tracer<T: SubtypeTracer>(
&mut self,
source: TypeId,
target: TypeId,
tracer: &mut T,
) -> bool
pub fn check_subtype_with_tracer<T: SubtypeTracer>( &mut self, source: TypeId, target: TypeId, tracer: &mut T, ) -> bool
Check if a type is a subtype of another, using the provided tracer.
This is the main entry point for tracer-based subtype checking. The tracer determines whether we collect detailed diagnostics or just return a boolean.
§Parameters
source: The source type (the “from” type insource <: target)target: The target type (the “to” type insource <: target)tracer: The tracer to use for failure handling
§Returns
trueifsourceis a subtype oftargetfalseotherwise
§Example
ⓘ
// Fast check
let mut fast = FastTracer;
let ok = checker.check_subtype_with_tracer(source, target, &mut fast);
// With diagnostics
let mut diag = DiagnosticTracer::new();
checker.check_subtype_with_tracer(source, target, &mut diag);
if let Some(reason) = diag.take_failure() {
eprintln!("Type error: {:?}", reason);
}Auto Trait Implementations§
impl<'a> Freeze for TracerSubtypeChecker<'a>
impl<'a> !RefUnwindSafe for TracerSubtypeChecker<'a>
impl<'a> !Send for TracerSubtypeChecker<'a>
impl<'a> !Sync for TracerSubtypeChecker<'a>
impl<'a> Unpin for TracerSubtypeChecker<'a>
impl<'a> UnsafeUnpin for TracerSubtypeChecker<'a>
impl<'a> !UnwindSafe for TracerSubtypeChecker<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more