Skip to content

feat: record the toolchain, refuse a lib schema, guard the std pin - #37

Merged
Kinflou merged 1 commit into
mainfrom
feat/lib-mode-manifest-details
Oct 12, 2026
Merged

Kinflou merged 1 commit into
mainfrom
feat/lib-mode-manifest-details

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 12, 2026

Copy link
Copy Markdown
Member

Three things lib mode needed before linking comline_std by default
becomes the CLI's behaviour (ComlineProject/cli#58).

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 carries
it now 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 (ComlineProject/core#91), 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.

After merging this

std-extra/Cargo.toml is regenerated here for the new rust-version line, so
STD_REV needs repointing at this PR's merge commit — which is exactly what
the new check will say on main if 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_std on. The import rewriting, the
dependency line and the absence of std's own files are now checked against a
real cargo build rather than against expected text.

Depends on ComlineProject/core#91.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant