Store concrete crate stores where possible
This commit is contained in:
parent
eb0bc64265
commit
5aec365cb9
19 changed files with 101 additions and 105 deletions
|
|
@ -13,6 +13,7 @@ use rustc::traits::{self, auto_trait as auto};
|
|||
use rustc::ty::{self, ToPredicate, TypeFoldable};
|
||||
use rustc::ty::subst::Subst;
|
||||
use rustc::infer::InferOk;
|
||||
use rustc::middle::cstore::CrateStore;
|
||||
use std::fmt::Debug;
|
||||
use syntax_pos::DUMMY_SP;
|
||||
|
||||
|
|
@ -20,13 +21,13 @@ use core::DocAccessLevels;
|
|||
|
||||
use super::*;
|
||||
|
||||
pub struct AutoTraitFinder<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||
pub cx: &'a core::DocContext<'a, 'tcx, 'rcx>,
|
||||
pub struct AutoTraitFinder<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> {
|
||||
pub cx: &'a core::DocContext<'a, 'tcx, 'rcx, 'cstore>,
|
||||
pub f: auto::AutoTraitFinder<'a, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> {
|
||||
pub fn new(cx: &'a core::DocContext<'a, 'tcx, 'rcx>) -> Self {
|
||||
impl<'a, 'tcx, 'rcx, 'cstore> AutoTraitFinder<'a, 'tcx, 'rcx, 'cstore> {
|
||||
pub fn new(cx: &'a core::DocContext<'a, 'tcx, 'rcx, 'cstore>) -> Self {
|
||||
let f = auto::AutoTraitFinder::new(&cx.tcx);
|
||||
|
||||
AutoTraitFinder { cx, f }
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use syntax_pos::Span;
|
|||
use rustc::hir;
|
||||
use rustc::hir::def::{Def, CtorKind};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::middle::cstore::LoadedMacro;
|
||||
use rustc::middle::cstore::{CrateStore, LoadedMacro};
|
||||
use rustc::ty;
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ pub struct Crate {
|
|||
pub masked_crates: FxHashSet<CrateNum>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'rcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||
impl<'a, 'tcx, 'rcx, 'cstore> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
||||
fn clean(&self, cx: &DocContext) -> Crate {
|
||||
use ::visit_lib::LibEmbargoVisitor;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ use rustc_driver::{self, driver, target_features, abort_on_err};
|
|||
use rustc::session::{self, config};
|
||||
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
|
||||
use rustc::hir::def::Def;
|
||||
use rustc::middle::cstore::CrateStore;
|
||||
use rustc::middle::privacy::AccessLevels;
|
||||
use rustc::ty::{self, TyCtxt, AllArenas};
|
||||
use rustc::hir::map as hir_map;
|
||||
|
|
@ -49,13 +48,13 @@ pub use rustc::session::search_paths::SearchPaths;
|
|||
|
||||
pub type ExternalPaths = FxHashMap<DefId, (Vec<String>, clean::TypeKind)>;
|
||||
|
||||
pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||
pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> {
|
||||
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
pub resolver: &'a RefCell<resolve::Resolver<'rcx>>,
|
||||
pub resolver: &'a RefCell<resolve::Resolver<'rcx, 'cstore>>,
|
||||
/// The stack of module NodeIds up till this point
|
||||
pub mod_ids: RefCell<Vec<NodeId>>,
|
||||
pub crate_name: Option<String>,
|
||||
pub cstore: Rc<dyn CrateStore>,
|
||||
pub cstore: Rc<CStore>,
|
||||
pub populated_all_crate_impls: Cell<bool>,
|
||||
// Note that external items for which `doc(hidden)` applies to are shown as
|
||||
// non-reachable while local items aren't. This is because we're reusing
|
||||
|
|
@ -87,7 +86,7 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> {
|
|||
pub all_traits: Vec<DefId>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
|
||||
impl<'a, 'tcx, 'rcx, 'cstore> DocContext<'a, 'tcx, 'rcx, 'cstore> {
|
||||
pub fn sess(&self) -> &session::Session {
|
||||
&self.tcx.sess
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ use doctree::*;
|
|||
// also, is there some reason that this doesn't use the 'visit'
|
||||
// framework from syntax?
|
||||
|
||||
pub struct RustdocVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||
pub struct RustdocVisitor<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> {
|
||||
pub module: Module,
|
||||
pub attrs: hir::HirVec<ast::Attribute>,
|
||||
pub cx: &'a core::DocContext<'a, 'tcx, 'rcx>,
|
||||
pub cx: &'a core::DocContext<'a, 'tcx, 'rcx, 'cstore>,
|
||||
view_item_stack: FxHashSet<ast::NodeId>,
|
||||
inlining: bool,
|
||||
/// Is the current module and all of its parents public?
|
||||
|
|
@ -49,8 +49,10 @@ pub struct RustdocVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
|
|||
exact_paths: Option<FxHashMap<DefId, Vec<String>>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||
pub fn new(cx: &'a core::DocContext<'a, 'tcx, 'rcx>) -> RustdocVisitor<'a, 'tcx, 'rcx> {
|
||||
impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
||||
pub fn new(
|
||||
cx: &'a core::DocContext<'a, 'tcx, 'rcx, 'cstore>
|
||||
) -> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
||||
// If the root is re-exported, terminate all recursion.
|
||||
let mut stack = FxHashSet();
|
||||
stack.insert(ast::CRATE_NODE_ID);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ use clean::{AttributesExt, NestedAttributesExt};
|
|||
|
||||
/// Similar to `librustc_privacy::EmbargoVisitor`, but also takes
|
||||
/// specific rustdoc annotations into account (i.e. `doc(hidden)`)
|
||||
pub struct LibEmbargoVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
|
||||
cx: &'a ::core::DocContext<'a, 'tcx, 'rcx>,
|
||||
pub struct LibEmbargoVisitor<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> {
|
||||
cx: &'a ::core::DocContext<'a, 'tcx, 'rcx, 'cstore>,
|
||||
// Accessibility levels for reachable nodes
|
||||
access_levels: RefMut<'a, AccessLevels<DefId>>,
|
||||
// Previous accessibility level, None means unreachable
|
||||
|
|
@ -32,8 +32,10 @@ pub struct LibEmbargoVisitor<'a, 'tcx: 'a, 'rcx: 'a> {
|
|||
visited_mods: FxHashSet<DefId>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'rcx> LibEmbargoVisitor<'a, 'tcx, 'rcx> {
|
||||
pub fn new(cx: &'a ::core::DocContext<'a, 'tcx, 'rcx>) -> LibEmbargoVisitor<'a, 'tcx, 'rcx> {
|
||||
impl<'a, 'tcx, 'rcx, 'cstore> LibEmbargoVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
||||
pub fn new(
|
||||
cx: &'a ::core::DocContext<'a, 'tcx, 'rcx, 'cstore>
|
||||
) -> LibEmbargoVisitor<'a, 'tcx, 'rcx, 'cstore> {
|
||||
LibEmbargoVisitor {
|
||||
cx,
|
||||
access_levels: cx.access_levels.borrow_mut(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue