Skip to main content

LightCheck

Trait LightCheck 

Source
pub trait LightCheck {
    // Required methods
    fn check_symbol_exists(&self, name: &str) -> bool;
    fn check_trait_impl(&self, type_name: &str, trait_name: &str) -> bool;
    fn check_derive_possible(
        &self,
        target: &str,
        trait_name: &str,
    ) -> CheckResult;

    // Provided methods
    fn pre_check(&self, _mutation_type: &str, _target: &str) -> CheckResult { ... }
    fn post_check(&self, _mutation_type: &str, _target: &str) -> CheckResult { ... }
}
Expand description

Trait for lightweight graph-based validation.

This trait defines the interface for pre-mutation validation checks that can quickly detect common errors without running the full compiler.

§Implementors

  • GraphChecker: Uses CodeGraph, TypeFlowGraph, and SymbolRegistry

§Usage

fn validate_mutation(checker: &impl LightCheck, target: &str) -> bool {
    if !checker.check_symbol_exists(target) {
        return false;
    }
    checker.check_derive_possible(target, "Default").is_ok()
}

For borrow conflict detection, use BorrowTrackerV2::conflicts() directly.

Required Methods§

Source

fn check_symbol_exists(&self, name: &str) -> bool

Check if a symbol exists in the codebase.

Searches both by full path (e.g., my_crate::MyStruct) and by short name (e.g., MyStruct).

Source

fn check_trait_impl(&self, type_name: &str, trait_name: &str) -> bool

Check if a type implements a trait.

First checks standard library implementations (primitives, common types), then searches the code graph for user-defined implementations.

Source

fn check_derive_possible(&self, target: &str, trait_name: &str) -> CheckResult

Check if a derive macro can be applied to a type.

Verifies that all fields of the type implement the required trait.

§Returns
  • CheckResult::Ok if derive is possible
  • CheckResult::Error with details about missing implementations

Provided Methods§

Source

fn pre_check(&self, _mutation_type: &str, _target: &str) -> CheckResult

Pre-check before applying a mutation.

This is called before mutation application to catch obvious errors quickly. Default implementation returns Ok.

Source

fn post_check(&self, _mutation_type: &str, _target: &str) -> CheckResult

Post-check after applying a mutation.

This is called after mutation application to verify the result. Default implementation returns Ok.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§