about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuietMisdreavus <grey@quietmisdreavus.net>2018-02-21 18:33:42 -0600
committerQuietMisdreavus <grey@quietmisdreavus.net>2018-02-21 18:33:42 -0600
commitef30a8fd1cd1efa1086a82976873490518fcb323 (patch)
tree00dbdada035b5fe258875a14e8cc09e88d7ca48f
parentd98449d110fe49355ae265623a5bbf6796525c92 (diff)
downloadrust-ef30a8fd1cd1efa1086a82976873490518fcb323.tar.gz
rust-ef30a8fd1cd1efa1086a82976873490518fcb323.zip
track extern traits being inlined
-rw-r--r--src/librustdoc/clean/inline.rs7
-rw-r--r--src/librustdoc/core.rs4
2 files changed, 10 insertions, 1 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index c09c6eab4d2..458c655df1d 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -494,11 +494,16 @@ fn separate_supertrait_bounds(mut g: clean::Generics)
 }
 
 pub fn record_extern_trait(cx: &DocContext, did: DefId) {
-    if cx.external_traits.borrow().contains_key(did) {
+    if cx.external_traits.borrow().contains_key(&did) &&
+        cx.active_extern_traits.borrow().contains(&did)
+    {
         return;
     }
 
+    cx.active_extern_traits.borrow_mut().push(did);
+
     let trait_ = build_external_trait(cx, did);
 
     cx.external_traits.borrow_mut().insert(did, trait_);
+    cx.active_extern_traits.borrow_mut().remove_item(&did);
 }
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 81babd803a5..e5d696882ab 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -58,6 +58,9 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> {
     pub renderinfo: RefCell<RenderInfo>,
     /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
     pub external_traits: RefCell<FxHashMap<DefId, clean::Trait>>,
+    /// Used while populating `external_traits` to ensure we don't process the same trait twice at
+    /// the same time.
+    pub active_extern_traits: RefCell<Vec<DefId>>,
     // The current set of type and lifetime substitutions,
     // for expanding type aliases at the HIR level:
 
@@ -236,6 +239,7 @@ pub fn run_core(search_paths: SearchPaths,
             populated_all_crate_impls: Cell::new(false),
             access_levels: RefCell::new(access_levels),
             external_traits: Default::default(),
+            active_extern_traits: Default::default(),
             renderinfo: Default::default(),
             ty_substs: Default::default(),
             lt_substs: Default::default(),