Don't store all traits in DocContext
This is already a query so we're just needlessly copying the data around.
This commit is contained in:
parent
00319519bb
commit
0347480151
@ -3,6 +3,7 @@ use rustc::traits;
|
||||
use rustc::ty::ToPredicate;
|
||||
use rustc::ty::subst::Subst;
|
||||
use rustc::infer::InferOk;
|
||||
use rustc::hir::def_id::LOCAL_CRATE;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
use super::*;
|
||||
@ -27,7 +28,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
|
||||
debug!("get_blanket_impls({:?})", ty);
|
||||
let mut impls = Vec::new();
|
||||
for &trait_def_id in self.cx.all_traits.iter() {
|
||||
for &trait_def_id in self.cx.tcx.all_traits(LOCAL_CRATE).iter() {
|
||||
if !self.cx.renderinfo.borrow().access_levels.is_public(trait_def_id) ||
|
||||
self.cx.generated_synthetics
|
||||
.borrow_mut()
|
||||
|
@ -68,7 +68,6 @@ pub struct DocContext<'tcx> {
|
||||
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
|
||||
// FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set.
|
||||
pub generated_synthetics: RefCell<FxHashSet<(Ty<'tcx>, DefId)>>,
|
||||
pub all_traits: Vec<DefId>,
|
||||
pub auto_traits: Vec<DefId>,
|
||||
}
|
||||
|
||||
@ -364,7 +363,6 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
let mut renderinfo = RenderInfo::default();
|
||||
renderinfo.access_levels = access_levels;
|
||||
|
||||
let all_traits = tcx.all_traits(LOCAL_CRATE).to_vec();
|
||||
let ctxt = DocContext {
|
||||
tcx,
|
||||
resolver,
|
||||
@ -379,10 +377,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
fake_def_ids: Default::default(),
|
||||
all_fake_def_ids: Default::default(),
|
||||
generated_synthetics: Default::default(),
|
||||
auto_traits: all_traits.iter().cloned().filter(|trait_def_id| {
|
||||
auto_traits: tcx.all_traits(LOCAL_CRATE).iter().cloned().filter(|trait_def_id| {
|
||||
tcx.trait_is_auto(*trait_def_id)
|
||||
}).collect(),
|
||||
all_traits,
|
||||
};
|
||||
debug!("crate: {:?}", tcx.hir().krate());
|
||||
|
||||
|
@ -4,7 +4,7 @@ use crate::fold::DocFolder;
|
||||
use super::Pass;
|
||||
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::def_id::{LOCAL_CRATE, DefId};
|
||||
use syntax::symbol::sym;
|
||||
|
||||
pub const COLLECT_TRAIT_IMPLS: Pass = Pass {
|
||||
@ -116,7 +116,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
||||
|
||||
// `tcx.crates()` doesn't include the local crate, and `tcx.all_trait_implementations`
|
||||
// doesn't work with it anyway, so pull them from the HIR map instead
|
||||
for &trait_did in cx.all_traits.iter() {
|
||||
for &trait_did in cx.tcx.all_traits(LOCAL_CRATE).iter() {
|
||||
for &impl_node in cx.tcx.hir().trait_impls(trait_did) {
|
||||
let impl_did = cx.tcx.hir().local_def_id(impl_node);
|
||||
inline::build_impl(cx, impl_did, None, &mut new_items);
|
||||
|
Loading…
Reference in New Issue
Block a user