Skip to content

Allow merging all libcore/alloc doctests into a single binary#153072

Open
jyn514 wants to merge 6 commits intorust-lang:mainfrom
ferrocene:jyn/libcore-doctest-merge
Open

Allow merging all libcore/alloc doctests into a single binary#153072
jyn514 wants to merge 6 commits intorust-lang:mainfrom
ferrocene:jyn/libcore-doctest-merge

Conversation

@jyn514
Copy link
Member

@jyn514 jyn514 commented Feb 25, 2026

This is only the changes needed to allow merging the tests. This doesn't actually turn doctest merging on in bootstrap. I think that might be a useful follow-up, since it makes them much faster to run, but it's not without downsides because it means we'll no longer be testing that doctests have all necessary feature() attributes.

The motivation for this change is to run the tests with -C instrument-coverage and then generate a coverage report from the output. Currently, this is very expensive because it requires parsing DWARF for each doctest binary. Merging the binaries decreases the time taken from several hours to ~30 seconds.


There are several parts to this change, most of which are independent and I'm happy to split out into other PRs.

  • Upgrade process spawning logging from debug->info so it's easier to see, including in a rustdoc built without debug symbols.
  • Core doctests now support being run with -C panic=abort. Ferrocene needs this downstream for complicated reasons; it's a one-line change so I figured it's not a big deal.
  • Downgrade errors about duplicate features from a hard error to a warning. The meaning is clear here, and doctest merging often creates duplicate features since it lifts them all to the crate root. This involves changes to the compiler but generally I expect this to be low-impact.
    • Enable this new warning, as well as several related feature lints, in rustdoc. By default rustdoc doesn't lint on anything except the lints it manually adds.
  • Rustdoc now treats allow(incomplete_features) as a crate-level attribute, just like internal_features. Without this, it's possible to get hard errors if rustdoc lifts features to the crate level but not allows.
  • Core doctests now support being built with --merge-doctests=yes. In particular, I removed a few $crate usages and explicitly marked a few doctests as standalone_crate.

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2026

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 25, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2026

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 68 candidates
  • Random selection from 13 candidates

@rust-log-analyzer

This comment has been minimized.

@jyn514 jyn514 force-pushed the jyn/libcore-doctest-merge branch from 16227c8 to d567da2 Compare February 25, 2026 04:30
@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Feb 25, 2026
@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Feb 25, 2026

Merging doctest would mean that we did no longer test that the set of features in doc tests are accurate, right? Those are visible to the user.

@rust-bors

This comment has been minimized.

@jyn514
Copy link
Member Author

jyn514 commented Feb 25, 2026

Yes. That’s why this doesn’t actually switch on merging, as mentioned in the description.

@jyn514 jyn514 force-pushed the jyn/libcore-doctest-merge branch from d567da2 to 4254825 Compare February 28, 2026 22:25
@rustbot
Copy link
Collaborator

rustbot commented Feb 28, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants