Repository navigation
feat: record the toolchain, refuse a lib schema, guard the std pin - #37
Merged
Merged
Conversation
Three things `lib` mode needed before linking `comline_std` by default becomes the CLI's behaviour. **The manifest states its toolchain.** A target names `rust#1.70.0` and the generated `Cargo.toml` said nothing about it, leaving a consumer to discover the required toolchain by failing to build. `GenRequest::lang_version` now carries it and `cargo_toml` emits `rust-version`. **A schema named `lib` is refused rather than silently winning.** `lib` mode writes the crate root at `src/lib.rs` first and then every schema at `src/<namespace>.rs`, so a `lib.ids` produced a second `src/lib.rs`; the CLI writes the list in order, so the schema replaced the crate root and the whole `pub mod` tree vanished with no diagnostic anywhere. Core refuses that name when a package is compiled, but `GenRequest` is a public contract, so a caller building one by hand is told instead of wrecked. **`STD_REV` is checked, not just `std-extra/`'s contents.** Once `lib` links std by default, every consumer reaches it through that pinned rev, so a correctly regenerated `std-extra/` with a pin still on the previous commit ships the old std to everyone and nothing fails. `--check-pin` diffs `std-extra/` between `STD_REV` and `HEAD`. It is deliberately its own flag rather than part of `--check`: regenerating `std-extra/` and repointing `STD_REV` at it cannot happen in one commit - the rev to point at is the merge commit, which does not exist yet - so folding them together would fail every PR that legitimately changes std's output, this one included. CI runs it on `main` only, with full history, since the check needs `STD_REV` to be in the clone. `std-extra/` is regenerated for the new `rust-version` line; its own pin needs repointing at this PR's merge commit afterwards, which is exactly what the new check will say if it is forgotten. Also proves the claim rather than asserting it: the compile test is now parameterised, and a second case builds a crate that imports a std type with `external_std` on - so the import rewriting, the dependency line and the absence of std's own files are checked against a real `cargo build`, not against expected text.
This was referenced Oct 12, 2026
This was referenced Oct 12, 2026
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.
Three things
libmode needed before linkingcomline_stdby defaultbecomes the CLI's behaviour (ComlineProject/cli#58).
The manifest states its toolchain. A target names
rust#1.70.0and thegenerated
Cargo.tomlsaid nothing about it, leaving a consumer to discoverthe required toolchain by failing to build.
GenRequest::lang_versioncarriesit now and
cargo_tomlemitsrust-version.A schema named
libis refused rather than silently winning.libmodewrites the crate root at
src/lib.rsfirst and then every schema atsrc/<namespace>.rs, so alib.idsproduced a secondsrc/lib.rs; the CLIwrites the list in order, so the schema replaced the crate root and the whole
pub modtree vanished with no diagnostic anywhere. Core refuses that namewhen a package is compiled (ComlineProject/core#91), but
GenRequestis apublic contract, so a caller building one by hand is told instead of wrecked.
STD_REVis checked, not juststd-extra/'s contents. Onceliblinksstd by default, every consumer reaches it through that pinned rev — so a
correctly regenerated
std-extra/with a pin still on the previous commitships the old std to everyone and nothing fails.
--check-pindiffsstd-extra/betweenSTD_REVandHEAD.It is deliberately its own flag rather than part of
--check: regeneratingstd-extra/and repointingSTD_REVat it cannot happen in one commit — therev to point at is the merge commit, which does not exist yet — so folding
them together would fail every PR that legitimately changes std's output,
this one included. CI runs it on
mainonly, with full history, since thecheck needs
STD_REVto be in the clone.After merging this
std-extra/Cargo.tomlis regenerated here for the newrust-versionline, soSTD_REVneeds repointing at this PR's merge commit — which is exactly whatthe new check will say on
mainif it is forgotten.Proving it, not asserting it
The compile test is parameterised, and a second case builds a crate that
imports a std type with
external_stdon. The import rewriting, thedependency line and the absence of std's own files are now checked against a
real
cargo buildrather than against expected text.Depends on ComlineProject/core#91.