-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add stability tags to ImportItem. #83900
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @CraftSpider (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Could you include a picture/screenshot of the new output, and add a test case to ensure it is output or not as expected? The test should go in |
This just needs a test, updating the labels |
@CraftSpider OK, should be good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patience! CC @jyn514 if you wouldn't mind taking a look, as this affects frontend, otherwise I'm happy to merge this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just nits, overall this looks great :)
"<tr><td><code>{}{}</code></td></tr>", | ||
myitem.visibility.print_with_space(cx.tcx(), myitem.def_id, cx.cache()), | ||
import.print(cx.cache(), cx.tcx()), | ||
"<tr class=\"{stab}{add}module-item\">\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure module-item
is correct here? These aren't modules, they're imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduced an import-item
class.
This comment has been minimized.
This comment has been minimized.
|
I had to do some more changes in order to support Portability tags, and I've added tests for Deprecated, Portability, and Unstable. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind squashing the commits? 24 is a little much 😅
src/librustdoc/clean/inline.rs
Outdated
@@ -477,6 +477,7 @@ fn build_module( | |||
}], | |||
}, | |||
did: None, | |||
attrs: None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add attrs
as a new field? You can look this up on-demand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jyn514 Because if I understand correctly, I would have to do
let attrs = Box::new(cx.tcx().get_attrs(def_id).clean(cx));
in print_item.rs
, and it didn't seem appropriate to call clean()
methods at that stage, not least because clean()
expects a DocContext
, and we don't have that in print_item.rs
.
Let me know if you see a better way!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it didn't seem appropriate to call clean() methods at that stage, not least because clean() expects a DocContext, and we don't have that in print_item.rs.
Got it, thanks. At this point, I think I would extract a free function in clean::types
for stability_class
so you only have to pass in the DefId of the item, not a whole clean::Item
. Note that stability_class
never uses the attributes, only the DefId. I would rather not make rustdoc slower just because the API is bad.
You'll have to also extract free functions for stability
, deprecation
, and is_fake
; all that seems fine.
cc #83183
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do that, but I would still have to pass in attrs
, and it also wouldn't solve the issue with the fake Item
. You see, the problem isn't so much with stability_class
, but rather with extra_info_tags
. It really does seem to need an Item
with attrs
on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ok. I guess this is a larger refactor than really belongs in this PR, I opened #84304.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, there's a simpler way: impl Clean for [ast::Attribute]
doesn't use DocContext at all:
rust/src/librustdoc/clean/mod.rs
Line 242 in b021bee
Attributes::from_ast(cx.sess().diagnostic(), self, None) |
So you can remove the
attrs
field and call let attrs = Box::new(Attributes::from_ast(tcx.sess().diagnostic(), tcx.get_attrs(def_id), None));
on-demand instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, should be good now.
Yep, CSS changes look good to me (and the rest of the code too 😉 ). @bors: r=jyn514,GuillaumeGomez |
📌 Commit e2a77b3 has been approved by |
…illaumeGomez Add stability tags to ImportItem. Fixes rust-lang#83832.
@GuillaumeGomez this is not yet ready to merge: #83900 (comment) @bors r- |
Outch sorry, went too quickly... |
This comment has been minimized.
This comment has been minimized.
@bors r+ This is great, thank you for sticking with it! |
📌 Commit 64a68ae has been approved by |
☀️ Test successful - checks-actions |
Fixes #83832.