]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #48415 - QuietMisdreavus:traits-on-traits-on-traits, r=Manishearth
authorManish Goregaokar <manishsmail@gmail.com>
Sat, 24 Feb 2018 23:52:11 +0000 (15:52 -0800)
committerGitHub <noreply@github.com>
Sat, 24 Feb 2018 23:52:11 +0000 (15:52 -0800)
rustdoc: don't crash when an external trait's docs needs to import another trait

Fixes https://github.com/rust-lang/rust/issues/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.

1  2 
src/librustdoc/clean/inline.rs
src/librustdoc/core.rs

Simple merge
Simple merge