diff options
Diffstat (limited to 'src/librustdoc/core.rs')
| -rw-r--r-- | src/librustdoc/core.rs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 81babd803a5..57773e4e068 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -11,13 +11,14 @@ use rustc_lint; use rustc_driver::{self, driver, target_features, abort_on_err}; use rustc::session::{self, config}; -use rustc::hir::def_id::DefId; +use rustc::hir::def_id::{DefId, CrateNum}; 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; use rustc::lint; -use rustc::util::nodemap::FxHashMap; +use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_resolve as resolve; use rustc_metadata::creader::CrateLoader; use rustc_metadata::cstore::CStore; @@ -48,6 +49,8 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> { pub resolver: &'a RefCell<resolve::Resolver<'rcx>>, /// The stack of module NodeIds up till this point pub mod_ids: RefCell<Vec<NodeId>>, + pub crate_name: Option<String>, + pub cstore: Rc<CrateStore>, 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 @@ -65,6 +68,11 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> { pub ty_substs: RefCell<FxHashMap<Def, clean::Type>>, /// Table node id of lifetime parameter definition -> substituted lifetime pub lt_substs: RefCell<FxHashMap<DefId, clean::Lifetime>>, + pub send_trait: Option<DefId>, + pub fake_def_ids: RefCell<FxHashMap<CrateNum, DefId>>, + pub all_fake_def_ids: RefCell<FxHashSet<DefId>>, + /// Maps (type_id, trait_id) -> auto trait impl + pub generated_synthetics: RefCell<FxHashSet<(DefId, DefId)>> } impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> { @@ -107,6 +115,7 @@ pub fn run_core(search_paths: SearchPaths, triple: Option<String>, maybe_sysroot: Option<PathBuf>, allow_warnings: bool, + crate_name: Option<String>, force_unstable_if_unmarked: bool) -> (clean::Crate, RenderInfo) { // Parse, resolve, and typecheck the given crate. @@ -230,9 +239,19 @@ pub fn run_core(search_paths: SearchPaths, .collect() }; + let send_trait; + + if crate_name == Some("core".to_string()) { + send_trait = clean::get_trait_def_id(&tcx, &["marker", "Send"], true); + } else { + send_trait = clean::get_trait_def_id(&tcx, &["core", "marker", "Send"], false) + } + let ctxt = DocContext { tcx, resolver: &resolver, + crate_name, + cstore: cstore.clone(), populated_all_crate_impls: Cell::new(false), access_levels: RefCell::new(access_levels), external_traits: Default::default(), @@ -240,6 +259,10 @@ pub fn run_core(search_paths: SearchPaths, ty_substs: Default::default(), lt_substs: Default::default(), mod_ids: Default::default(), + send_trait: send_trait, + fake_def_ids: RefCell::new(FxHashMap()), + all_fake_def_ids: RefCell::new(FxHashSet()), + generated_synthetics: RefCell::new(FxHashSet()) }; debug!("crate: {:?}", tcx.hir.krate()); |
