test(units): trybuild compile-fail cases for dimensional errors #39
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "patman/uom-trybuild"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this does
Adds
trybuildcompile-fail tests that assert the typed units layer rejects dimensionally incoherent code — the negative guardrail the in-crate#[test]s cannot express (a passing test can't prove a compile error). Cases incommon/tests/ui/:length_plus_time.rs—Length + Time(incoherent add).angular_bare_operator.rs—Angle / Timewithout.into()(the documentedAngleKindtrap; useangular::DivDt).boundary_type_mismatch.rs— passing aLengthwhere aVelocityis expected.⚠️ For evaluation — cargo-only, not in buck2
trybuild shells out to cargo to compile each ui case, which the hermetic buck2 sandbox can't provide. So this is not wired into the buck2 test graph (
tests/is outsidecommon/BUCK'ssrc/**glob, andtrybuildis acommon/Cargo.tomldev-dep only — the buck2 graph and third-partyBUCKare untouched;buck2 test //common/...still passes 89).Run it with cargo:
The generated
.stderrfiles are not committed yet (they need a cargo run to produce); commit them once reviewed.The decision to make
This is the crux you wanted to evaluate: trybuild gives real compile-fail enforcement but only under cargo, which conflicts with the buck2-only build mandate. Options: (a) accept a cargo-only enforcement lane for compile-fail tests (run in a cargo CI job); (b) invest in a custom buck2 rule that asserts compile failure (no cargo); (c) drop trybuild and rely on the
compile_faildoctests in #37 as documentation only. No buck2 wiring is included pending your call.Stack position
PR 4 of 4. Based on #38 (angular helpers) → #37 → #36. Merge order: #36 → #37 → #38 → #39.