rustdoc: Render impl restriction#157310
Open
CoCo-Japan-pan wants to merge 2 commits into
Open
Conversation
Member
GuillaumeGomez
requested changes
Jun 2, 2026
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
fmease
reviewed
Jun 2, 2026
f4e407f to
5358c2f
Compare
GuillaumeGomez
approved these changes
Jun 2, 2026
Member
|
Thanks! r=me once CI is happy. @bors delegate |
Contributor
|
✌️ @CoCo-Japan-pan, you can now approve this pull request! If @GuillaumeGomez told you to " |
jhpratt
approved these changes
Jun 2, 2026
Urgau
approved these changes
Jun 2, 2026
Member
|
@bors r=GuillaumeGomez,jhpratt,Urgau |
Contributor
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jun 2, 2026
…tion, r=GuillaumeGomez,jhpratt,Urgau rustdoc: Render `impl` restriction According to the [Zulip conversation](https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/Documenting.20.60impl.60.20restrictions/with/598960498), this PR implements the rendering of `impl` restrictions. Following the pattern used for `#[rustc_must_implement_one_of]`, this adds an information note saying, "This trait cannot be implemented outside \<crate-name\>". When `--document-private-items` is passed, the note instead says, "This trait cannot be implemented outside \<path-to-module\>". The screenshots show the generated documentation for the following code: ```rust pub mod inner { pub impl(self) trait Bar {} } ``` in a crate `c`. The latter image corresponds to the case where `--document-private-items` is passed. Tracking issue: rust-lang#105077 r? @Urgau cc @jhpratt <img width="920" height="309" alt="screenshot" src="https://github.com/user-attachments/assets/586c97d6-0f41-41de-9673-eaf12b96c4a1" /> <img width="902" height="316" alt="document-private-screenshot" src="https://github.com/user-attachments/assets/56aedc38-bd05-4ece-885a-8d928a59089c" />
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
According to the Zulip conversation, this PR implements the rendering of
implrestrictions.Following the pattern used for
#[rustc_must_implement_one_of], this adds an information note saying, "This trait cannot be implemented outside <crate-name>".When
--document-private-itemsis passed, the note instead says, "This trait cannot be implemented outside <path-to-module>".The screenshots show the generated documentation for the following code:
in a crate
c. The latter image corresponds to the case where--document-private-itemsis passed.Tracking issue: #105077
r? @Urgau
cc @jhpratt