Skip to content

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Oct 3, 2025

This PR makes rustdoc respect -Z unstable options when collecting doctests (rustdoc --test).

In the process I also realized that --error-format wasn't respected as well, making UI annotations impossible to write so I fixed that as well.

Best reviewed commit by commit.

Fixes #147276
Fixes #143930
r? fmease

@rustbot rustbot added 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. labels Oct 3, 2025
@rustbot

This comment was marked as resolved.

@fmease

This comment was marked as resolved.

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Very nice

r=me with suggestions applied in one way or another (feel free to ignore those you find unnecessarily churn-y).

View changes since this review

LL | //! ```
| ^^^^^^^
LL | //!
| ^^^
Copy link
Member

Choose a reason for hiding this comment

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

(unrelated, preexisting) Lol, we really gotta improve the span finding heuristic for all of these cases...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the spans are really rough. I think no one realized how bad they were until now.

Copy link
Member

@fmease fmease Oct 3, 2025

Choose a reason for hiding this comment

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

Once -Zcrate-attr or feature used_with_args is stabilized, this test will break. The author that tries to stabilize any of these will then have to deal with the failures and wonder with what to replace this test or if they could even remove it.

Is there any "perma"-unstable option we could use instead or alongside -Zcrate-attr? If you don't have the time or inclination to go look for one, could you add some kind of NOTE: If any of these options/features get stabilized, please replace with another unstable one to both tests? Thanks, much appreciated!

Copy link
Member Author

Choose a reason for hiding this comment

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

I quickly looked at our unstable options and nothing stand out from a quick look.

The only thing I can think of would be to emit a check-cfg warning and use -Zcheck-cfg-all-expected=yes to show all the values in the diagnostic, but that seems quite hacky to me.

remap_path_prefix: options.remap_path_prefix.clone(),
unstable_opts: options.unstable_opts.clone(),
error_format: options.error_format.clone(),
..config::Options::default()
Copy link
Member

Choose a reason for hiding this comment

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

I guess ideally we would either exhaustively destructure RustdocOptions at the start of the function or exhaustively construct config::Options to prevent such mistakes in the futures (hell, I don't even know if there are still any options we want to copy over); but yeah, it's probably not feasible due to the sheer amount of options...

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2025
@Urgau Urgau force-pushed the rustdoc-test-unstable_opts branch from 89f3ae7 to c1443e2 Compare October 3, 2025 15:05
@Urgau
Copy link
Member Author

Urgau commented Oct 3, 2025

@bors r=fmease

@bors
Copy link
Collaborator

bors commented Oct 3, 2025

📌 Commit c1443e2 has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 3, 2025
bors added a commit that referenced this pull request Oct 3, 2025
Rollup of 5 pull requests

Successful merges:

 - #147245 (only replace the intended comma in pattern suggestions)
 - #147269 (Add regression test for 123953)
 - #147277 (Extract common logic for iterating over features)
 - #147292 (Respect `-Z` unstable options in `rustdoc --test`)
 - #147300 (Add xtensa arch to object file creation)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…r=fmease

Respect `-Z` unstable options in `rustdoc --test`

This PR makes rustdoc respect `-Z` unstable options when collecting doctests (`rustdoc --test`).

In the process I also realized that `--error-format` wasn't respected as well, making UI annotations impossible to write so I fixed that as well.

Best reviewed commit by commit.

Fixes rust-lang#147276
Fixes rust-lang#143930
r? fmease
bors added a commit that referenced this pull request Oct 4, 2025
Rollup of 14 pull requests

Successful merges:

 - #142670 (Document fully-qualified syntax in `as`' keyword doc)
 - #144908 (Fix doctest output json)
 - #145685 (add CloneFromCell and Cell::get_cloned)
 - #146330 (Bump unicode_data and printables to version 17.0.0)
 - #146451 (Fix atan2 inaccuracy in documentation)
 - #146479 (add mem::conjure_zst)
 - #147190 (std: `sys::net` cleanups)
 - #147245 (only replace the intended comma in pattern suggestions)
 - #147251 (Do not assert that a change in global cache only happens when concurrent)
 - #147269 (Add regression test for 123953)
 - #147277 (Extract common logic for iterating over features)
 - #147280 (Return to needs-llvm-components being info-only)
 - #147292 (Respect `-Z` unstable options in `rustdoc --test`)
 - #147300 (Add xtensa arch to object file creation)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 4, 2025
…r=fmease

Respect `-Z` unstable options in `rustdoc --test`

This PR makes rustdoc respect `-Z` unstable options when collecting doctests (`rustdoc --test`).

In the process I also realized that `--error-format` wasn't respected as well, making UI annotations impossible to write so I fixed that as well.

Best reviewed commit by commit.

Fixes rust-lang#147276
Fixes rust-lang#143930
r? fmease
bors added a commit that referenced this pull request Oct 4, 2025
Rollup of 5 pull requests

Successful merges:

 - #147245 (only replace the intended comma in pattern suggestions)
 - #147269 (Add regression test for 123953)
 - #147277 (Extract common logic for iterating over features)
 - #147292 (Respect `-Z` unstable options in `rustdoc --test`)
 - #147300 (Add xtensa arch to object file creation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit dbc5e72 into rust-lang:master Oct 4, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 4, 2025
rust-timer added a commit that referenced this pull request Oct 4, 2025
Rollup merge of #147292 - Urgau:rustdoc-test-unstable_opts, r=fmease

Respect `-Z` unstable options in `rustdoc --test`

This PR makes rustdoc respect `-Z` unstable options when collecting doctests (`rustdoc --test`).

In the process I also realized that `--error-format` wasn't respected as well, making UI annotations impossible to write so I fixed that as well.

Best reviewed commit by commit.

Fixes #147276
Fixes #143930
r? fmease
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Regression in nightly-2025-06-28: rustdoc --test -Zcrate-attr=feature(used_with_arg) rustdoc --test doesn't recognize register_tool
4 participants