Skip to content

Allow #![doc(test(attr(..)))] everywhere #140560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented May 1, 2025

This PR adds the ability to specify #![doc(test(attr(..)))] at module level everywhere in addition to allowing it at crate-root.

This is motivated by a recent PR #140323 (by @tgross35) where we have to duplicate 2 attributes to every single f16 and f128 doctests, by allowing #![doc(test(attr(..)))] at module level (and everywhere else) we can omit them entirely and just have (in both module):

#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128))))]
#![doc(test(attr(expect(internal_features))))]

Those new attributes are appended to the one found at crate-root or at a previous module. Those "global" attributes are compatible with merged doctests (they already were before).

Given the small addition that this is, I'm proposing to insta-stabilize it, but I can feature-gate it if preferred.

Best reviewed commit by commit.

r? @GuillaumeGomez

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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-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. labels May 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 1, 2025

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@Urgau Urgau force-pushed the test_attr-module-level branch from 516b680 to 715421c Compare May 1, 2025 19:57
@rust-log-analyzer

This comment has been minimized.

@Urgau Urgau force-pushed the test_attr-module-level branch from 715421c to 7dbac96 Compare May 1, 2025 21:13
@rust-log-analyzer

This comment has been minimized.

@Urgau Urgau force-pushed the test_attr-module-level branch from 7dbac96 to ebd7505 Compare May 1, 2025 22:46
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label May 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 1, 2025

This PR modifies run-make tests.

cc @jieyouxu

@GuillaumeGomez GuillaumeGomez added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. A-doctests Area: Documentation tests, run by rustdoc and removed T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels May 2, 2025
Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

Some small changes needed but otherwise it's pretty good as is. Once done, I'll start the FCP.

@rustbot rustbot 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 May 2, 2025
@Urgau Urgau removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 2, 2025
@Urgau Urgau force-pushed the test_attr-module-level branch from ebd7505 to 746ceb9 Compare May 2, 2025 14:04
@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 May 2, 2025
@GuillaumeGomez
Copy link
Member

Just one last nit, I'll start the FCP afterward. Please note that I will add a concern about whether it should overload existing doc(test(attr(...))) (from the parent module) or if the current approach (appending to parent module's) is the one we want.

@Urgau Urgau force-pushed the test_attr-module-level branch from 746ceb9 to 5a3cad2 Compare May 2, 2025 14:32
@Urgau Urgau force-pushed the test_attr-module-level branch from 6e8c327 to d96d3be Compare May 22, 2025 18:16
@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels May 28, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented May 28, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jun 7, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Jun 7, 2025

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@GuillaumeGomez
Copy link
Member

Thanks everyone!

@bord r+ rollup

@GuillaumeGomez
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 7, 2025

📌 Commit d96d3be has been approved by GuillaumeGomez

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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 7, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 7, 2025
…illaumeGomez

Allow `#![doc(test(attr(..)))]` everywhere

This PR adds the ability to specify [`#![doc(test(attr(..)))]`](https://doc.rust-lang.org/nightly/rustdoc/write-documentation/the-doc-attribute.html#testattr) ~~at module level~~ everywhere in addition to allowing it at crate-root.

This is motivated by a recent PR rust-lang#140323 (by `@tgross35)` where we have to duplicate 2 attributes to every single `f16` and `f128` doctests, by allowing `#![doc(test(attr(..)))]` at module level (and everywhere else) we can omit them entirely and just have (in both module):

```rust
#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128))))]
#![doc(test(attr(expect(internal_features))))]
```

Those new attributes are appended to the one found at crate-root or at a previous module. Those "global" attributes are compatible with merged doctests (they already were before).

Given the small addition that this is, I'm proposing to insta-stabilize it, but I can feature-gate it if preferred.

Best reviewed commit by commit.

r? `@GuillaumeGomez`
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 7, 2025
…illaumeGomez

Allow `#![doc(test(attr(..)))]` everywhere

This PR adds the ability to specify [`#![doc(test(attr(..)))]`](https://doc.rust-lang.org/nightly/rustdoc/write-documentation/the-doc-attribute.html#testattr) ~~at module level~~ everywhere in addition to allowing it at crate-root.

This is motivated by a recent PR rust-lang#140323 (by ``@tgross35)`` where we have to duplicate 2 attributes to every single `f16` and `f128` doctests, by allowing `#![doc(test(attr(..)))]` at module level (and everywhere else) we can omit them entirely and just have (in both module):

```rust
#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128))))]
#![doc(test(attr(expect(internal_features))))]
```

Those new attributes are appended to the one found at crate-root or at a previous module. Those "global" attributes are compatible with merged doctests (they already were before).

Given the small addition that this is, I'm proposing to insta-stabilize it, but I can feature-gate it if preferred.

Best reviewed commit by commit.

r? ``@GuillaumeGomez``
bors added a commit that referenced this pull request Jun 7, 2025
Rollup of 14 pull requests

Successful merges:

 - #138062 (Enable Non-determinism of float operations in Miri and change std tests )
 - #140560 (Allow `#![doc(test(attr(..)))]` everywhere)
 - #141001 (Make NonZero<char> possible)
 - #141295 (Stabilize `if let` guards (`feature(if_let_guard)`))
 - #141435 (Add (back) `unsupported_calling_conventions` lint to reject more invalid calling conventions)
 - #141447 (Document representation of `Option<unsafe fn()>`)
 - #142008 (const-eval error: always say in which item the error occurred)
 - #142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`)
 - #142065 (Stabilize `const_eq_ignore_ascii_case`)
 - #142116 (Fix bootstrap tracing imports)
 - #142126 (Treat normalizing consts like normalizing types in deeply normalize)
 - #142140 (compiler: Sort and doc ExternAbi variants)
 - #142148 (compiler: Treat ForceWarning as a Warning for diagnostic level)
 - #142154 (get rid of spurious cfg(bootstrap))

r? `@ghost`
`@rustbot` modify labels: rollup
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 7, 2025
…illaumeGomez

Allow `#![doc(test(attr(..)))]` everywhere

This PR adds the ability to specify [`#![doc(test(attr(..)))]`](https://doc.rust-lang.org/nightly/rustdoc/write-documentation/the-doc-attribute.html#testattr) ~~at module level~~ everywhere in addition to allowing it at crate-root.

This is motivated by a recent PR rust-lang#140323 (by ```@tgross35)``` where we have to duplicate 2 attributes to every single `f16` and `f128` doctests, by allowing `#![doc(test(attr(..)))]` at module level (and everywhere else) we can omit them entirely and just have (in both module):

```rust
#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128))))]
#![doc(test(attr(expect(internal_features))))]
```

Those new attributes are appended to the one found at crate-root or at a previous module. Those "global" attributes are compatible with merged doctests (they already were before).

Given the small addition that this is, I'm proposing to insta-stabilize it, but I can feature-gate it if preferred.

Best reviewed commit by commit.

r? ```@GuillaumeGomez```
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 7, 2025
…illaumeGomez

Allow `#![doc(test(attr(..)))]` everywhere

This PR adds the ability to specify [`#![doc(test(attr(..)))]`](https://doc.rust-lang.org/nightly/rustdoc/write-documentation/the-doc-attribute.html#testattr) ~~at module level~~ everywhere in addition to allowing it at crate-root.

This is motivated by a recent PR rust-lang#140323 (by ````@tgross35)```` where we have to duplicate 2 attributes to every single `f16` and `f128` doctests, by allowing `#![doc(test(attr(..)))]` at module level (and everywhere else) we can omit them entirely and just have (in both module):

```rust
#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128))))]
#![doc(test(attr(expect(internal_features))))]
```

Those new attributes are appended to the one found at crate-root or at a previous module. Those "global" attributes are compatible with merged doctests (they already were before).

Given the small addition that this is, I'm proposing to insta-stabilize it, but I can feature-gate it if preferred.

Best reviewed commit by commit.

r? ````@GuillaumeGomez````
bors added a commit that referenced this pull request Jun 7, 2025
Rollup of 9 pull requests

Successful merges:

 - #140560 (Allow `#![doc(test(attr(..)))]` everywhere)
 - #141447 (Document representation of `Option<unsafe fn()>`)
 - #141661 (Make the `dangerous_implicit_autorefs` lint deny-by-default)
 - #142065 (Stabilize `const_eq_ignore_ascii_case`)
 - #142116 (Fix bootstrap tracing imports)
 - #142126 (Treat normalizing consts like normalizing types in deeply normalize)
 - #142140 (compiler: Sort and doc ExternAbi variants)
 - #142148 (compiler: Treat ForceWarning as a Warning for diagnostic level)
 - #142154 (get rid of spurious cfg(bootstrap))

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-doctests Area: Documentation tests, run by rustdoc A-run-make Area: port run-make Makefiles to rmake.rs disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants