-
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
Show whether a trait is object-safe on its document page #85138
Comments
rust/compiler/rustc_middle/src/ty/mod.rs Line 1896 in 2fb1dee
for the rustdoc side, just query the doc context with a given trait_def_id. |
@rustbot claim |
@csmoe Can you tell what are the relevant parts of rustdoc that needs to be changed? |
@vramana sorry for late rely :) rust/src/librustdoc/clean/inline.rs Lines 213 to 220 in ac923d9
Add a is_object_safe field to clean::Trait , its value can be queried with cx.tcx.is_object_safe(did) like is_auto .
Then you can append the object-safety info into the render part here rust/src/librustdoc/html/render/print_item.rs Line 462 in ac923d9
I know little about the render code, @jyn514 could you leave some notes about that? |
No, please do not add more fields to Trait. Query I don't know much about render, @GuillaumeGomez may have suggestions. |
I'm actually not sure what they want the end result to look like, so I don't know where to tell them to update the code. ;) |
@GuillaumeGomez maybe it could be a cube icon to the right of the new If @vramana doesn't want to work on it I'd be happy to give it a go. |
Following up from the PR with some UI discussion. I'd prefer not to add more icons up at the top of the page; we're already a bit crowded with icons. And there's no icon that has a broadly understood meaning of "object safe". I like the approach in #89553, to write out "This trait is object-safe." But that PR puts it all the way at the top of the page, which is very high priority - and I would say object safety is more medium priority, so it should be lower on the page. One possibility would be to make an What about this: Under "Implementors", we could have at the very top "This trait is object safe. References to types that implement this trait can be automatically coerced to |
I don't think this is necessarily true, you can have a |
@jyn514 Just out of curiosity, how can I have a |
@EFanZh I don't think that's actually true, I misremembered. |
We have one 👍🏻 on:
Would anyone else like to weigh in? Good enough to proceed with implementation? |
Any update on this? :) |
I'm not sure if it's already been suggested, but what about only showing a note if the trait is not object-safe? |
I like @camelid's suggestion to only show when a trait is not object safe, since that's the more unusual condition. If we do that, it doesn't fit logically under "Implementors" anymore. If we proceed with only marking non-object-safe traits, here are a couple of ideas:
|
I think it’s still fine to mention under “Implementors” like “This trait is not object safe: I see this issue doesn’t have an assignee currently, can I claim this? |
You can but since we didn't reach a consensus, any PR would hang around until we reach one. |
Rollup merge of rust-lang#113241 - poliorcetics:85138-doc-object-safety, r=GuillaumeGomez rustdoc: Document lack of object safety on affected traits Closes rust-lang#85138 I saw the issue didn't have any recent activity, if there is another MR for it I missed it. I want the issue to move forward so here is my proposition. It takes some space just before the "Implementors" section and only if the trait is **not** object safe since it is the only case where special care must be taken in some cases and this has the benefit of avoiding generation of HTML in (I hope) the common case.
So that it is easy for user to recognize object-safe traits.
The text was updated successfully, but these errors were encountered: