-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
rustdoc ICE fix: When collecting Deref impls with their targets, skip the negative ones
#154444
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #![feature(negative_impls)] | ||
| #![crate_name = "foo"] | ||
|
|
||
| // Regression test for https://github.com/rust-lang/rust/issues/128801 | ||
| // Negative `Deref`/`DerefMut` impls should not cause an ICE and should still be rendered. | ||
|
|
||
| pub struct Source; | ||
|
|
||
| //@ has foo/struct.Source.html | ||
|
|
||
| // Verify negative Deref impl is rendered in the main content. | ||
| //@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl !Deref for Source' | ||
|
|
||
| // Verify negative DerefMut impl is rendered in the main content. | ||
| //@ has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl !DerefMut for Source' | ||
|
|
||
| // Verify negative impls appear in the sidebar. | ||
| //@ has - '//div[@class="sidebar-elems"]//h3/a[@href="#trait-implementations"]' 'Trait Implementations' | ||
| //@ has - '//*[@class="sidebar-elems"]//section//a' '!Deref' | ||
| //@ has - '//*[@class="sidebar-elems"]//section//a' '!DerefMut' | ||
|
|
||
| impl !std::ops::Deref for Source {} | ||
| impl !std::ops::DerefMut for Source {} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| //@ check-pass | ||
|
|
||
| // Regression test for https://github.com/rust-lang/rust/issues/128801 | ||
| // Negative `Deref`/`DerefMut` impls should not cause an ICE. | ||
|
|
||
| #![feature(negative_impls)] | ||
|
|
||
| pub struct Source; | ||
|
|
||
| impl !std::ops::Deref for Source {} | ||
| impl !std::ops::DerefMut for Source {} |
Oops, something went wrong.
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.
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.
The two
build_implfns (one inclean/mod.rs, the other inclean/mod.rs) also invoke extra code when encounteringDereftrait impls by callingbuild_deref_target_impls. Likewise, inrender/sidebar.rswe have two places that perform extra work for deref impls.I'm relatively sure that all four of these places still process negative deref trait impls, likely unnecessarily so. If it's not too much work for you, could you filter out negative impls in these places (unless it's impossible for negative deref impls to show up there). It probably doesn't save that much or any processing time but it might be more robust.
If you do that it might also be worth adding a HTML test in
tests/rustdoc-htmlto ensure that we still actually renderimpl !Deref for …impls (in the sidebar and the main container).Uh oh!
There was an error while loading. Please reload this page.
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.
@fmease, thank you for reviewing the PR. 🙂
I take it you mean clean/mod.rs and clean/inline.rs, as well as
clean_implandbuild_impl, respectively? I pushed a commit that addresses the suggestion for those four sites, and adds an HTML test. 🙂Thanks again! Let me know if there’s anything else I’m missing here.
@rustbot ready
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.
@fmease, would you be able to take a look at this again? I made the requested change. Thanks! 🙂
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.
Ah yes, haha. Silly typo.
Thanks for addressing my feedback! Sorry, the PR slipped through the cracks because apparently rustbot still doesn't honor
@rustbot readyin review comments, so this PR didn't show up using my usual filter.