docs(core): add compile-checked doctests for type-compatibility rules - #3108
docs(core): add compile-checked doctests for type-compatibility rules#3108phil-opp wants to merge 1 commit into
Conversation
`types_match` and `CompatibilityGraph::is_compatible` encode several non-obvious rules that were only described in prose: the wildcard behavior of an unparameterized side, the "shared key must agree" (vs. disjoint-key) parameter semantics, the universal `* -> Bytes` sink, and the depth-3 bound on transitive widening chains. Add `# Examples` doctests that pin each of these semantics so they are compile-checked and cannot silently regress. Documentation only; no behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PYiYgEo2WKBXfGooqP2WG5
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Automated codebase-review run — summaryThis is the summary for a batch of machine-generated PRs from one automated review pass over PRs opened, by categoryCorrectness
Documentation
Rejected / deferred findings (with reasons)
Validation (once, on the combined diff of all 5 PRs)
Each PR is a draft and clearly attributed to Claude (Claude Code). Please review carefully before merging — these are machine-generated. Generated by Claude Code |
|
Reviewed the doctests against the actual implementations in
The API paths ( 🤖 Automated review by Claude (Claude Code). This review was generated fully automatically with no human in the loop and has not been vetted by a maintainer — treat it as advisory. Generated by Claude Code |
Issue
libraries/core/src/types.rsexposes two public type-compatibility helpers whose behavior is subtle but was only documented in prose:types_match— an unparameterized side is a wildcard, and parameter conflicts are only rejected on shared keys (disjoint keys never conflict).CompatibilityGraph::is_compatible— the universal* -> std/core/v1/Bytessink, same-base wildcard matching, and a depth-3 bound on transitive widening chains (BFS).None of these rules were exercised by a compile-checked doctest, so a refactor could silently change them without any in-file test catching it. Sibling public APIs in the crate (e.g.
config::ByteSize) already carry doctests.Fix
Add
# Examplesdoctests to both functions that pin the intended semantics:types_match: identical match, unparameterized wildcard, disjoint-key compatibility, shared-key conflict, different-base mismatch.is_compatible:Bytessink, one-hop and two-hop (UInt8 -> UInt32 -> UInt64) built-in widening, same-base wildcard, and a four-rule chain demonstrating that three hops are reachable but four are beyond the depth limit.Documentation only — no behavior change.
Validation
origin/mainbefore opening. Please review carefully before merging.🤖 Generated with Claude Code
Generated by Claude Code