Skip to main content

solve

pub fn solve(ctx: &PassCtx<'_>, diff: &mut ASTDiff)
Expand description

MatchIdenticalDiagnosticStatements: pairs up still-unmatched calls/macros that look like they’re meant for the programmer rather than the end user - logging (log::error!, logger.warn(...)), error bailouts (bail!, panic!), assertions, debug printfs - whenever the entire statement is byte-for-byte identical on both sides. See crate::diff::nodes::is_diagnostic_statement for exactly what counts.

Runs as part of phase 2 of the matching pipeline (Diff::pending_with_config lists all ten phases), right after phase 1’s hash descent and before phase 4’s syntax-aware matching, the terminal residual resolution and the move-detection fallback. Running it after phase 1 means it only ever picks up statements phase 1’s byte-identical/structural hash matching left behind, so it can’t fragment a match a bigger/more-reliable pass would otherwise have made in one piece (e.g. matching a whole function wholesale) into a smaller one anchored on some incidental identical log::debug!(...) call inside it. Running it before the later phases means it can still find a diagnostic statement buried inside a function/impl that has no same-named counterpart on the other side.

Validated only by its own unit tests (including non-Rust ones covering C/Python/Go callee extraction); no corpus fixture exercises it - see “Design history moved out of source” in src/diff/TODO.md for why the fixture that motivated it does not.

Matching requires an exact full-content hash match (see ASTMetadata::node_to_full_hash) - no similarity threshold. A log::error!("failed: {e}") that only changed on one side is deliberately left for the final APTED pass to size up as an Update, since this pass has no basis for deciding two non-identical diagnostic statements are “the same” one.