Adopt cargo-cgp as CGP's first-class error toolchain#258
Merged
Conversation
- Remove the cgp-compile-fail-tests suite and cgp-test-crate-a/-b (migrated to cargo-cgp UI fixtures); drop the rust-src pin that only that suite needed. - Error catalog: link the cargo-cgp UI fixtures (GitHub URLs), add a "How cargo-cgp presents it" section per class, keep the raw diagnostics as a fallback, and add error_codes/cargo-cgp-codes.md. - Add docs/reference/cargo-cgp.md; update the CGP skill with must-have install/use guidance, version-check behaviour, and the "don't touch RA settings" caveat; lead the debugging guide with cargo-cgp (hand techniques as fallback). - Communication strategy: position cargo-cgp as removing the unreadable-errors adoption obstacle (honesty-calibrated; alpha conceded). - AGENTS.md: add the cross-project discovery/GitHub-link/sync rules and redirect the fixture-capture workflow to cargo-cgp. - README: recommend installing cargo-cgp when getting started, and clarify it is optional and that CGP builds on stable Rust. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI Overview
This PR makes CGP treat
cargo-cgpas its first-class, recommended tool for reading compiler errors, and moves the post-codegen compile-fail tests out of this repository to where that tool lives. It changes documentation, tests, and the project's cross-repository conventions only — no library crate, public API, or macro behavior is touched.Why this change
The obstacle CGP's users cite most is not conceptual but practical: because a CGP macro expands to ordinary Rust, a small wiring mistake is caught by the compiler type-checking the generated code, so it surfaces as a wall of errors naming types the programmer never wrote, with the real cause buried or hidden.
cargo-cgpis the tool built to fix exactly that — it re-runs the check under the next-generation trait solver and rewrites the errors it recognizes into a compact, root-cause-first form with[CGP-Exxx]codes. Until now this repository documented that tool as a future aspiration and kept its owntrybuildcompile-fail suite to pin the raw diagnostics; this PR catches the docs up to reality and consolidates the testing where it belongs.High-level concepts
The change rests on four ideas, each worked out across the docs and tests below. cargo-cgp is now the recommended way to build, check, and debug CGP code, so the skill, the debugging guide, the README, and the communication strategy all lead with it rather than with by-hand error tracing. The post-codegen compile-fail cases have one home, and it is cargo-cgp, because a
cargo-cgpUI fixture snapshots both the raw compiler output and the tool's reshaped output side by side, which is a strictly better artifact than the raw-onlytrybuildsnapshot this repository used to keep. The error catalog is the shared reference between the two projects, documenting each error class from both sides — the raw diagnostic (as a fallback for when the tool is absent) and howcargo-cgppresents it — and linking the fixture that pins it. The two projects are one system in two repositories, so the PR codifies how they find each other, how they link to each other, and when a change in one obligates a change in the other.Structural changes
The removals are the largest structural move. The
cgp-compile-fail-testscrate and the two cross-crate helper cratescgp-test-crate-aandcgp-test-crate-bare deleted, dropping the workspace from four test crates to two (cgp-testsandcgp-macro-testsremain); their post-codegen and cross-crate coverage now lives as UI fixtures in cargo-cgp. Therust-toolchain.tomlpin drops therust-srccomponent, which existed only so one compile-fail snapshot could render a standard-library source line deterministically.The documentation gains two new files and restructures one section. A new tooling reference document,
docs/reference/cargo-cgp.md, describes installing and using the tool for a reader who works only in this repository, and a newdocs/errors/error_codes/cargo-cgp-codes.mdcatalogs the tool's[CGP-Exxx]codes as a pointer into cargo-cgp's own authoritative list. Every class document underdocs/errors/is restructured to carry a renamed The raw diagnostic section (kept as the fallback) plus a new How cargo-cgp presents it section, and its fixture links now point at the cargo-cgp UI fixtures as GitHub URLs.The remaining edits update the knowledge base's guidance and voice. The
/cgpskill gains a prominent, must-have tooling section; the debugging guide is reordered to lead with the tool and treat the hand techniques as a fallback; the communication-strategy documents reposition the errors obstacle as one being actively removed; and bothAGENTS.mdfiles, the docs index, the guides index, and the implementation docs are updated to redirect the old fixture-capture workflow and to state the new cross-project rules. The top-levelREADME.mdrecommends installing cargo-cgp when getting started. All cross-project links from this repository to cargo-cgp are written as GitHub URLs.Impacts
The impacts fall into five areas. Read the area lead-ins to find the ones that affect you, and the bullets for the specifics.
Testing and CI shift the most, because a whole test target is gone:
cargo nextest run --workspaceno longer runs any post-codegen compile-fail tests — that coverage moved to cargo-cgp — so the workspace test count drops and the run is faster.cgp-compile-fail-tests(for examplecargo nextest run -p cgp-compile-fail-testsorTRYBUILD=overwrite cargo test -p cgp-compile-fail-tests) will now fail, because the crate no longer exists, and must be removed.cgp-test-crate-a/-bno longer run here; their compile-time coverage is preserved as a cargo-cgpok/fixture, but the small set of runtimeassert_eq!checks crate-b carried are not executed by cargo-cgp's compile-and-snapshot harness.rust-srcis no longer installed by the toolchain file, so a fresh build or CI fetches slightly less, and the standard-library-snippet determinism caveat that pin addressed is gone from this repository.cargo testhere — a heavier loop, and the trade for getting the reader-facing output pinned.Contributor and agent workflow changes, so the documented process is different:
ok/acceptable/usability), not as anacceptable/problematictrybuildfixture here; rejection cases the macro catches still stay incgp-macro-tests.Documentation is broadly rewritten, so readers see a different story:
[CGP-Exxx]form, so it doubles as the reference behind the tool's output.Users of the CGP library are affected only in what they are advised to install, not in what they build:
cargo check/cargo build/cargo run/cargo testwork unchanged, and cargo-cgp's pinned nightly is used only for its owncheck.The known limitations are documented rather than left silent:
inheritance_cycleclass has no automated coverage, because it compiles cleanly under cargo-cgp's next-generation solver — recorded as a next-solver divergence rather than dropped quietly.rustcoutput), which the catalog and the tool's own issue tracker state openly.What this PR does not change
No library crate, its version, its public API, its prelude, or any macro's expansion is modified, so the change is safe to merge on those grounds alone: it is a documentation, test-suite, and cross-project-convention change. The published crates and their MSRV are untouched,
cargo publish --workspaceis unaffected (the removed crates were alreadypublish = false), and a downstream user who never adopts cargo-cgp sees no difference in how CGP compiles.