Uh oh!
There was an error while loading. Please reload this page.
rustdoc: don't crash when an external trait's docs needs to import another trait - #48415
Merged
bors merged 4 commits intoFeb 25, 2018
Merged
Conversation
rust-highfive
commented
Feb 22, 2018
Contributor
(rust_highfive has picked a reviewer for you, use r? to override) |
Manishearth
commented
Feb 22, 2018
Member
r=me but needs a test |
Manishearth
commented
Feb 22, 2018
Member
The test I had was pubtraitFoo{/// [x](::Bar)fnfoo();}pubtraitBar{/// [x](::Foo)fnfoo();}and then pubuse aux::Foo;pubuse aux::Bar; |
Manishearth
commented
Feb 22, 2018
Member
I have a test at https://github.com/manishearth/rust/tree/rustdoc-trait-ice , but haven't run it yet |
QuietMisdreavus
commented
Feb 22, 2018
ContributorAuthor
The test i wrote up was: /// Woah, this trait links to [OtherTrait](OtherTrait)!pubtraitSomeTrait{}/// Woah, this trait links to [SomeTrait](SomeTrait)!pubtraitOtherTrait{}#[doc(inline)]pubuse issue_48414::{SomeTrait,OtherTrait};...which still stack-overflows. |
Manishearth
commented
Feb 22, 2018
Member
wooooooooooo |
QuietMisdreavus
commented
Feb 22, 2018
ContributorAuthor
It turns out, i wrote a |
Manishearth
commented
Feb 22, 2018
Member
@bors r+ |
bors
commented
Feb 22, 2018
Collaborator
📌 Commit 8872e7b has been approved by |
Manishearth added a commit
to Manishearth/rust
that referenced
this pull request
Feb 24, 2018
…-traits, r=Manishearth rustdoc: don't crash when an external trait's docs needs to import another trait Fixesrust-lang#48414 When resolving intra-paths for an item, rustdoc needs to have information about their items on hand, for proper bookkeeping. When loading a path for an external item, it needs to load these items from their host crate, since their information isn't otherwise available. This includes resolving paths for those docs. which can cause this process to recurse. Rustdoc keeps a map of external traits in a `RefCell<HashMap<DefId, Trait>>`, and it keeps a borrow of this active when importing an external trait. In the linked crash, this led to a RefCell borrow error, panic, and ICE. This PR manually releases the borrow while importing the trait, and also keeps a list of traits being imported at the given moment. The latter keeps rustdoc from infinitely recursing as it tries to import the same trait repeatedly.
bors added a commit
that referenced
this pull request
Feb 25, 2018
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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes#48414
When resolving intra-paths for an item, rustdoc needs to have information about their items on hand, for proper bookkeeping. When loading a path for an external item, it needs to load these items from their host crate, since their information isn't otherwise available. This includes resolving paths for those docs. which can cause this process to recurse. Rustdoc keeps a map of external traits in a
RefCell<HashMap<DefId, Trait>>, and it keeps a borrow of this active when importing an external trait. In the linked crash, this led to a RefCell borrow error, panic, and ICE.This PR manually releases the borrow while importing the trait, and also keeps a list of traits being imported at the given moment. The latter keeps rustdoc from infinitely recursing as it tries to import the same trait repeatedly.