Skip to main content

Module check

Module check 

Source
Expand description

Lightweight graph-based compilation safety checks.

This module provides fast pre-mutation validation using the existing CodeGraph and SymbolRegistry infrastructure. It’s not a full type checker, but catches common mutation errors quickly.

§Design Philosophy

  • Speed over completeness: 10-100x faster than cargo check
  • Leverage existing infrastructure: Uses CodeGraph edges and SymbolRegistry
  • Fail fast: Catch obvious errors before expensive compilation

§Capabilities

  • Symbol existence checks
  • Known trait implementation verification
  • Derive possibility checks (field types implement required traits)
  • Borrow conflict analysis (via DataFlowGraphV2::borrow_analysis())

§Limitations

Cannot handle: generics resolution, type inference, complex lifetimes. Use cargo check for final validation.

§Usage

use ryo_analysis::{GraphChecker, CodeGraph, SymbolRegistry};

let checker = GraphChecker::new(&graph, &typeflow, &registry);

// Quick symbol existence check
if checker.check_symbol_exists("MyStruct") {
    // Symbol exists
}

// Check if derive is possible
match checker.check_derive_possible("MyStruct", "Default") {
    CheckResult::Ok => { /* proceed with mutation */ }
    CheckResult::Error(errors) => { /* abort or cascade */ }
    _ => {}
}

// Borrow conflict detection: use BorrowTrackerV2.conflicts() directly
let tracker = dataflow.borrow_tracker();
let conflicts = tracker.conflicts(var_id, BorrowKind::Mutable, 10);

Structs§

CascadeResult
Result of a cascade operation.
CheckWarning
Warning from a light check.
GraphChecker
Lightweight graph-based checker for pre-mutation validation.

Enums§

CascadeMutation
A mutation to be applied as part of cascade.
CascadeStatus
Status of cascade operation.
CascadeStrategy
Strategy for handling cascade failures.
CheckError
Error from a light check.
CheckResult
Result of a lightweight graph-based check.

Traits§

LightCheck
Trait for lightweight graph-based validation.

Functions§

cascade_add_derive
Cascade derive to dependent types.