Skip to main content

ryo_analysis/check/
mod.rs

1//! Lightweight graph-based compilation safety checks.
2//!
3//! This module provides fast pre-mutation validation using the existing
4//! `CodeGraph` and `SymbolRegistry` infrastructure. It's not a full type checker,
5//! but catches common mutation errors quickly.
6//!
7//! # Design Philosophy
8//!
9//! - **Speed over completeness**: 10-100x faster than `cargo check`
10//! - **Leverage existing infrastructure**: Uses `CodeGraph` edges and `SymbolRegistry`
11//! - **Fail fast**: Catch obvious errors before expensive compilation
12//!
13//! # Capabilities
14//!
15//! - Symbol existence checks
16//! - Known trait implementation verification
17//! - Derive possibility checks (field types implement required traits)
18//! - Borrow conflict analysis (via `DataFlowGraphV2::borrow_analysis()`)
19//!
20//! # Limitations
21//!
22//! Cannot handle: generics resolution, type inference, complex lifetimes.
23//! Use `cargo check` for final validation.
24//!
25//! # Usage
26//!
27//! ```rust,ignore
28//! use ryo_analysis::{GraphChecker, CodeGraph, SymbolRegistry};
29//!
30//! let checker = GraphChecker::new(&graph, &typeflow, &registry);
31//!
32//! // Quick symbol existence check
33//! if checker.check_symbol_exists("MyStruct") {
34//!     // Symbol exists
35//! }
36//!
37//! // Check if derive is possible
38//! match checker.check_derive_possible("MyStruct", "Default") {
39//!     CheckResult::Ok => { /* proceed with mutation */ }
40//!     CheckResult::Error(errors) => { /* abort or cascade */ }
41//!     _ => {}
42//! }
43//!
44//! // Borrow conflict detection: use BorrowTrackerV2.conflicts() directly
45//! let tracker = dataflow.borrow_tracker();
46//! let conflicts = tracker.conflicts(var_id, BorrowKind::Mutable, 10);
47//! ```
48
49mod cascade;
50mod checker;
51mod result;
52mod traits;
53
54pub use cascade::{
55    cascade_add_derive, CascadeMutation, CascadeResult, CascadeStatus, CascadeStrategy,
56};
57pub use checker::GraphChecker;
58pub use result::{CheckError, CheckResult, CheckWarning};
59pub use traits::LightCheck;