-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Hide repr attribute from doc of types without guaranteed repr #107680
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r=me, but I want to get some additional eyes from libs-api + libs (nominated) -- I think it's worth at least raising awareness for future additions of repr in std, so we can consider always employing this pattern. |
One other thought: we may want to explicitly document when the repr can be relied on with at least a code-comment (i.e., not doc comment), so that we can be more explicit about when it is public API and when not. |
I think #66401 is the proper way of handling this: rustdoc should only show I don't think we should pollute the standard library with these |
I agree with @Amanieu. It might still need the approval of the rest of the team but I think it's a better approach. |
It sounds like I prefer adding these few attributes so that the burden is on standard library maintainers until the rustdoc bug is fixed, while @Amanieu prefers not adding these attributes so the burden is on users until the rustdoc bug is fixed (and also on standard library maintainers in mediating situations where users have reached a faulty understanding of standard library guarantees due to misleading rustdoc rendered documentation, and also on standard library maintainers in the Path/PathBuf/OsStr case where the same rustdoc bug has been worked around in a worse way than this; see #105018 (review)). |
☔ The latest upstream changes (presumably #111169) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#107680 (Hide repr attribute from doc of types without guaranteed repr) - rust-lang#111488 (Use error term in projection if missing associated item in new solver) - rust-lang#111533 (Handle error body in generator layout) - rust-lang#111573 (Erase `ReError` properly) - rust-lang#111592 (Change Vec examples to not assert exact capacity except where it is guaranteed) - rust-lang#111610 (fix(diagnostic): wrap parens for ref impl trait param) - rust-lang#111642 ([rustdoc] Only keep impl blocks from bodies) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Rustdoc has an undesirable behavior of blindly copying
repr
into the documentation of structs and enums, even when there is no particular repr that the type guarantees to its users. This is a source of confusion for standard library users who assume the fact that a repr is documented means it must be something the standard library promises they can rely on (in transmutes, or FFI).Some issues on the topic of rustdoc's incorrect handling of
repr
:#[repr(transparent)]
where the field is non-public #90435In places, the standard library currently works around this confusing rustdoc behavior by just omitting
repr(transparent)
altogether even where it should be required if equivalent code were being written outside of the standard library. See #61969.IMO that is even more confusing, even for standard library maintainers — see #105018 (comment). It's also not something that works for other reprs like
C
oru8
which cannot just be omitted even in standard library code.This PR tries a different approach for some types that are being currently incorrectly documented with a repr.