Skip to content

feat(rustdoc): stabilize --emit flag#146220

Open
weihanglo wants to merge 1 commit intorust-lang:mainfrom
weihanglo:rustdoc-emit
Open

feat(rustdoc): stabilize --emit flag#146220
weihanglo wants to merge 1 commit intorust-lang:mainfrom
weihanglo:rustdoc-emit

Conversation

@weihanglo
Copy link
Member

TODO: stabilization report?

r? rustdoc

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Sep 5, 2025
@weihanglo
Copy link
Member Author

Questions:

  • Do we want to stabilize also unversioned-shared-resources option? It currently does nothing AFAIK.
  • Do we want a stabilization report?
  • How many details do we want to put in doc?

@weihanglo
Copy link
Member Author

cc @aDotInTheVoid since you've involved in the PR removing the last blocker :)

@weihanglo weihanglo marked this pull request as ready for review September 24, 2025 19:21
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 24, 2025
@fmease fmease added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Oct 13, 2025
@notriddle notriddle self-assigned this Oct 13, 2025
@GuillaumeGomez
Copy link
Member

We discussed on today's rustdoc meeting. Before going any further, we will investigate exactly what each --emit option does exactly to have a clearer picture of what's actually needed and also to add missing documentation.

@weihanglo
Copy link
Member Author

We discussed on today's rustdoc meeting. Before going any further, we will investigate exactly what each --emit option does exactly to have a clearer picture of what's actually needed and also to add missing documentation.

Thanks for it!

This PR contains a doc based on my understanding and the history of these options, but I am not 100% sure if that is correct

@rustbot

This comment has been minimized.

@fmease
Copy link
Member

fmease commented Oct 25, 2025

I haven't read this yet but here are probably some very important and relevant considerations: #83784.

@weihanglo
Copy link
Member Author

For the use case in Cargo, we actually don't need anything other than dep-info. The originak ask was here: #t-rustdoc > Plan to stabilize `--emit=dep-info[=path]` @ 💬:

One thing that might be a blocker: rust-lang/cargo#15605

Do we want to stabilize the --emit flag with all the emit types, or just dep-info? At this moment it is required for cargo to pass --emit=toolchain-shared-resources,invocation-specific,dep-info=<PATH> in order to make the generated doc look good and styled.

I guess one way forward is that rustdoc provides an extra emit type, say, default. So that cargo can run --emit=default,dep-info=/path/to/foo.d without even considering those other options. And in rustdoc documentation we can state that the default emit type is whatever the default emits rustdoc is doing. Pretty much like --remap-path-scope=all:

all - an alias for all of the above, also equivalent to supplying only --remap-path-prefix without --remap-path-scope.

notriddle added a commit to notriddle/rust that referenced this pull request Oct 27, 2025
This option hasn't done anything for a long time, and can be
removed. I've kept a shim in place to avoid breaking docs.rs,
but the option no longer does anything.

Using git-blame, I tracked this option down to
f77ebd4, the commit that
introduced EmitType in the first place. It was used with
SharedResource::Unversioned, which no longer exists since
f9e1f6f removed them.

Part of rust-lang#146220
@notriddle
Copy link
Contributor

I've opened #148180, a follow-up that removes the no-op unversioned-shared-resources, which hasn't done anything ever since we switched to using hashes for cache busting.

notriddle added a commit to notriddle/rust that referenced this pull request Oct 27, 2025
This option hasn't done anything for a long time, and can be
removed. I've kept a shim in place to avoid breaking docs.rs,
but the option no longer does anything.

Using git-blame, I tracked this option down to
f77ebd4, the commit that
introduced EmitType in the first place. It was used with
SharedResource::Unversioned, which no longer exists since
f9e1f6f removed them.

CC rust-lang#146220
Part of rust-lang#83784
@rustbot

This comment has been minimized.

notriddle added a commit to notriddle/rust that referenced this pull request Oct 28, 2025
This option hasn't done anything for a long time, and can be
removed. I've kept a shim in place to avoid breaking docs.rs,
but the option no longer does anything.

Using git-blame, I tracked this option down to
f77ebd4, the commit that
introduced EmitType in the first place. It was used with
SharedResource::Unversioned, which no longer exists since
f9e1f6f removed them.

CC rust-lang#146220
Part of rust-lang#83784
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 28, 2025
…rces, r=GuillaumeGomez

rustdoc: remove `--emit=unversioned-shared-resources`

This option hasn't done anything for a long time, and can be removed. I've kept a shim in place to avoid breaking docs.rs, but the option no longer does anything.

Using git-blame, I tracked this option down to
f77ebd4, the commit that introduced EmitType in the first place. It was used with SharedResource::Unversioned, which no longer exists since f9e1f6f removed them.

CC rust-lang#146220
Part of rust-lang#83784
rust-timer added a commit that referenced this pull request Oct 28, 2025
Rollup merge of #148180 - notriddle:unversioned-shared-resources, r=GuillaumeGomez

rustdoc: remove `--emit=unversioned-shared-resources`

This option hasn't done anything for a long time, and can be removed. I've kept a shim in place to avoid breaking docs.rs, but the option no longer does anything.

Using git-blame, I tracked this option down to
f77ebd4, the commit that introduced EmitType in the first place. It was used with SharedResource::Unversioned, which no longer exists since f9e1f6f removed them.

CC #146220
Part of #83784
Copy link
Member Author

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has updated and removed the unversioned-shared-resources option, which was removed in #148180

View changes since this review

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 30, 2025
…=GuillaumeGomez

rustdoc: fix `--emit=dep-info` on scraped examples

Makes sure both stages (the scraping process itself, and the doc build) emit complete dependency lists.

CC rust-lang#146220
Part of rust-lang#83784
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 30, 2025
…=GuillaumeGomez

rustdoc: fix `--emit=dep-info` on scraped examples

Makes sure both stages (the scraping process itself, and the doc build) emit complete dependency lists.

CC rust-lang#146220
Part of rust-lang#83784
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 3, 2025
…=GuillaumeGomez

rustdoc: fix `--emit=dep-info` on scraped examples

Makes sure both stages (the scraping process itself, and the doc build) emit complete dependency lists.

CC rust-lang#146220
Part of rust-lang#83784
rust-timer added a commit that referenced this pull request Nov 3, 2025
Rollup merge of #148268 - notriddle:emit-scraped-examples, r=GuillaumeGomez

rustdoc: fix `--emit=dep-info` on scraped examples

Makes sure both stages (the scraping process itself, and the doc build) emit complete dependency lists.

CC #146220
Part of #83784
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Nov 4, 2025
…eGomez

rustdoc: fix `--emit=dep-info` on scraped examples

Makes sure both stages (the scraping process itself, and the doc build) emit complete dependency lists.

CC rust-lang/rust#146220
Part of rust-lang/rust#83784
@notriddle
Copy link
Contributor

I haven’t found any more problems with this feature (that don’t involve its interaction with other unstable features).

I think it can be stabilized in its current form.

@GuillaumeGomez

This comment was marked as resolved.

@rust-rfcbot

This comment was marked as resolved.

@GuillaumeGomez
Copy link
Member

@rfcbot fcp merge rustdoc

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Jan 12, 2026

Team member @GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jan 12, 2026
This flag controls the types of output by rustdoc. It accepts a comma-separated
list of values, and may be specified multiple times. The valid emit kinds are:

- `toolchain-shared-resources` --- Generates shared static files that their
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether these triple-dashes are considered standard :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a mdbook stuff. Not sure about rustdoc but Cargo book uses that everywhere

https://rust-lang.github.io/mdBook/format/markdown.html#smart-punctuation

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 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.

@fmease
Copy link
Member

fmease commented Feb 20, 2026

@rfcbot reviewed

Do we want a stabilization report?

I'd like to have a tiny stabilization report, just a few sentences esp. around the motivation would be great. For example, it's unclear to me right now whether Cargo is only interested in --emit=dep-info or if it also cares about the other two options toolchain-shared-resources & invocation-specific or rather the mechanism they enable, namely suppressing the emission of invocation-specific artifacts (via --emit=toolchain-shared-resources (sic!)) and shared resources (via --emit=invocation-specific (sic!)). That'd be useful to know imo.

@rfcbot concern tiny-stab-report

I've noticed that --emit=depinfo (i.e., default path) doesn't put the *.d file into the outdir but instead in the CWD. rustc does put in in the CWD by default but that's because the default outdir is the CWD. However, for rustdoc it's doc/. If you give rustc an --outdir=<DIR> it does put the *.d file into <DIR> while rustdoc completely ignores --outdir=<DIR> for depinfo.

Could we please honor the outdir?

@rfcbot concern outdir-not-honored

(minor bikeshedding) Re. the naming of toolchain-shared-resources and invocation-specific, it feels slightly off to me. I'll retract my concern immediately if everyone else is fine with these terms.

E.g., seeing the word toolchain in the context of the rustdoc binary seems a bit "weird". The (often rustup) toolchain is the set of rustc+rustdoc+docs+other components, they live at different level of abstraction? version-specific-shared-resources feels more natural, maybe? Although at this point, I'd just go with shared-resources. Isn't it obvious that these shared resources aren't stable across versions? If we hypothetically had a "stable rustdoc ABI", stable-shared-resources would do the trick, wouldn't it?

Re. --emit=invocation-specific, we're emitting an adjective here. I know, this is pure bikeshedding at this point and a noun like invocation-specific-data is hardly better?

@rfcbot concern naming

Lastly, what should we do if the user passes (stable) --test or (unstable) --output-format=doctest? Or if the user passes a *.md Markdown file to rustdoc (stable)? At the moment, --emit=dep-info doesn't emit any *.d file in these three cases because they take completely different execution paths in rustdoc. I'm leaning towards rejecting --emit=dep-info in these cases or is that too strict / artificially restricted? Or do we want to follow rustc's example: Under --test --emit=dep-info it doesn't generate any (test) binary, it only emits a *.d file.

@rfcbot concern interaction-with-other-modes


The following isn't an official concern and only tangentially related. I'm wondering whether --output-format=doctests (#134529) should actually be --emit=doctests. I'd also like to CC the proposed --print (#151618, print requests like rustc) for visibility, too. They're distinct but quite similar (I guess print requests are completely non-normal execution and emissions "happen on the side" during normal execution but they can also make execution halt early?).

Copy link
Member

@fmease fmease Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(non-blocking, just some impl cleanups we should do at some point)

  1. Under --emit=dep-info and --emit=invocation-specific rustdoc still generates an empty <OUTDIR>/static.files/ directory.
  2. On unknown emission/output types rustdoc doesn't list all legal types in the error diagnostic unlike rustc.

@notriddle
Copy link
Contributor

Re. the naming of toolchain-shared-resources and invocation-specific, it feels slightly off to me.

toolchain-shared-resources should probably be called static-files, because that's the name of the directory that it actually emits.

test-dingus % ls
lib.rs
test-dingus % rustdoc +nightly --emit=toolchain-shared-resources -Zunstable-options lib.rs
test-dingus % ls
doc	lib.rs
test-dingus % ls doc
static.files

Maybe the invocation-specific data should be called data-files? That one's harder to name, but we don't want to call it crate-files (because it might come from a standalone markdown file) and I think invocation-specific-files is needlessly complex for what it is.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 2, 2026
rustdoc: make `--emit` and `--out-dir` mimic rustc

The behavior in the test case matches rustc's:

    test-dingus % ls
    main.rs
    test-dingus % mkdir foobar
    test-dingus % rustc --emit=dep-info main.rs --out-dir=foobar
    test-dingus % ls
    foobar  main.rs
    test-dingus % ls foobar
    main.d
    test-dingus % rustc --emit=dep-info=testfile.d main.rs --out-dir=foobar
    test-dingus % ls
    foobar          main.rs         testfile.d
    test-dingus % ls foobar
    main.d

CC rust-lang#146220 (comment)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 2, 2026
rustdoc: make `--emit` and `--out-dir` mimic rustc

The behavior in the test case matches rustc's:

    test-dingus % ls
    main.rs
    test-dingus % mkdir foobar
    test-dingus % rustc --emit=dep-info main.rs --out-dir=foobar
    test-dingus % ls
    foobar  main.rs
    test-dingus % ls foobar
    main.d
    test-dingus % rustc --emit=dep-info=testfile.d main.rs --out-dir=foobar
    test-dingus % ls
    foobar          main.rs         testfile.d
    test-dingus % ls foobar
    main.d

CC rust-lang#146220 (comment)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 3, 2026
rustdoc: make `--emit` and `--out-dir` mimic rustc

The behavior in the test case matches rustc's:

    test-dingus % ls
    main.rs
    test-dingus % mkdir foobar
    test-dingus % rustc --emit=dep-info main.rs --out-dir=foobar
    test-dingus % ls
    foobar  main.rs
    test-dingus % ls foobar
    main.d
    test-dingus % rustc --emit=dep-info=testfile.d main.rs --out-dir=foobar
    test-dingus % ls
    foobar          main.rs         testfile.d
    test-dingus % ls foobar
    main.d

CC rust-lang#146220 (comment)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 3, 2026
rustdoc: make `--emit` and `--out-dir` mimic rustc

The behavior in the test case matches rustc's:

    test-dingus % ls
    main.rs
    test-dingus % mkdir foobar
    test-dingus % rustc --emit=dep-info main.rs --out-dir=foobar
    test-dingus % ls
    foobar  main.rs
    test-dingus % ls foobar
    main.d
    test-dingus % rustc --emit=dep-info=testfile.d main.rs --out-dir=foobar
    test-dingus % ls
    foobar          main.rs         testfile.d
    test-dingus % ls foobar
    main.d

CC rust-lang#146220 (comment)
rust-timer added a commit that referenced this pull request Mar 3, 2026
Rollup merge of #153003 - notriddle:emit-outdir, r=fmease

rustdoc: make `--emit` and `--out-dir` mimic rustc

The behavior in the test case matches rustc's:

    test-dingus % ls
    main.rs
    test-dingus % mkdir foobar
    test-dingus % rustc --emit=dep-info main.rs --out-dir=foobar
    test-dingus % ls
    foobar  main.rs
    test-dingus % ls foobar
    main.d
    test-dingus % rustc --emit=dep-info=testfile.d main.rs --out-dir=foobar
    test-dingus % ls
    foobar          main.rs         testfile.d
    test-dingus % ls foobar
    main.d

CC #146220 (comment)
@fmease
Copy link
Member

fmease commented Mar 4, 2026

@rfcbot resolve outdir-not-honored

Fixed in #153003. Thanks, notriddle!

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants