track extern traits being inlined

This commit is contained in:
QuietMisdreavus 2018-02-21 18:33:42 -06:00
parent d98449d110
commit ef30a8fd1c
2 changed files with 10 additions and 1 deletions

View file

@ -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);
}

View file

@ -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(),