Skip to content
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

Merged
merged 7 commits into from
Apr 20, 2021
Merged

Conversation

torhovland
Copy link
Contributor

Fixes #83832.

@rust-highfive
Copy link
Collaborator

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 5, 2021
@torhovland torhovland marked this pull request as ready for review April 5, 2021 19:49
@CraftSpider
Copy link
Contributor

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 src/test/rustdoc, you can look at other tests there for examples.

@torhovland
Copy link
Contributor Author

torhovland commented Apr 6, 2021

image

@CraftSpider
Copy link
Contributor

This just needs a test, updating the labels
@rustbot label: -S-waiting-on-review +S-waiting-on-author

@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 Apr 7, 2021
@torhovland
Copy link
Contributor Author

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 src/test/rustdoc, you can look at other tests there for examples.

@CraftSpider OK, should be good now.

Copy link
Contributor

@CraftSpider CraftSpider left a 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.

src/test/rustdoc/issue-83832.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 13, 2021
Copy link
Member

@jyn514 jyn514 left a 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 :)

src/librustdoc/html/render/print_item.rs Outdated Show resolved Hide resolved
"<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\">\
Copy link
Member

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.

Copy link
Contributor Author

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.

src/librustdoc/html/render/print_item.rs Outdated Show resolved Hide resolved
src/librustdoc/html/render/print_item.rs Outdated Show resolved Hide resolved
src/test/rustdoc/issue-83832.rs Outdated Show resolved Hide resolved
src/test/rustdoc/issue-83832.rs Outdated Show resolved Hide resolved
src/test/rustdoc/issue-83832.rs Outdated Show resolved Hide resolved
src/test/rustdoc/issue-83832.rs Outdated Show resolved Hide resolved
src/test/rustdoc/issue-83832.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 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 Apr 13, 2021
@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented Apr 13, 2021

clean::Item is the one you want.

@torhovland
Copy link
Contributor Author

I had to do some more changes in order to support Portability tags, and I've added tests for Deprecated, Portability, and Unstable.

@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 14, 2021
@bors

This comment has been minimized.

Copy link
Member

@jyn514 jyn514 left a 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 😅

@@ -477,6 +477,7 @@ fn build_module(
}],
},
did: None,
attrs: None,
Copy link
Member

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.

Copy link
Contributor Author

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!

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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:

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.

Copy link
Contributor Author

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.

@jyn514 jyn514 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 Apr 18, 2021
@GuillaumeGomez
Copy link
Member

Yep, CSS changes look good to me (and the rest of the code too 😉 ).

@bors: r=jyn514,GuillaumeGomez

@bors
Copy link
Contributor

bors commented Apr 18, 2021

📌 Commit e2a77b3 has been approved by jyn514,GuillaumeGomez

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 18, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 18, 2021
…illaumeGomez

Add stability tags to ImportItem.

Fixes rust-lang#83832.
@jyn514
Copy link
Member

jyn514 commented Apr 18, 2021

@GuillaumeGomez this is not yet ready to merge: #83900 (comment)

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 18, 2021
@GuillaumeGomez
Copy link
Member

Outch sorry, went too quickly...

@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented Apr 20, 2021

@bors r+

This is great, thank you for sticking with it!

@bors
Copy link
Contributor

bors commented Apr 20, 2021

📌 Commit 64a68ae has been approved by jyn514

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 20, 2021
@bors
Copy link
Contributor

bors commented Apr 20, 2021

⌛ Testing commit 64a68ae with merge a70fbf6...

@bors
Copy link
Contributor

bors commented Apr 20, 2021

☀️ Test successful - checks-actions
Approved by: jyn514
Pushing a70fbf6 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 20, 2021
@bors bors merged commit a70fbf6 into rust-lang:master Apr 20, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 20, 2021
@torhovland torhovland deleted the issue-83832 branch April 20, 2021 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustdoc should show Unstable notices next to re-exported items
8 participants