Remove src field from ExternCrate
This commit is contained in:
parent
25c15cdbe0
commit
5407a69aa4
4 changed files with 14 additions and 6 deletions
|
@ -86,8 +86,6 @@ impl Clean<ExternalCrate> for CrateNum {
|
|||
fn clean(&self, cx: &mut DocContext<'_>) -> ExternalCrate {
|
||||
let tcx = cx.tcx;
|
||||
let root = DefId { krate: *self, index: CRATE_DEF_INDEX };
|
||||
let krate_span = tcx.def_span(root);
|
||||
let krate_src = cx.sess().source_map().span_to_filename(krate_span);
|
||||
|
||||
// Collect all inner modules which are tagged as implementations of
|
||||
// primitives.
|
||||
|
@ -195,8 +193,8 @@ impl Clean<ExternalCrate> for CrateNum {
|
|||
};
|
||||
|
||||
ExternalCrate {
|
||||
crate_num: *self,
|
||||
name: tcx.crate_name(*self),
|
||||
src: krate_src,
|
||||
attrs: tcx.get_attrs(root).clean(cx),
|
||||
primitives,
|
||||
keywords,
|
||||
|
|
|
@ -72,13 +72,21 @@ crate struct TraitWithExtraInfo {
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
crate struct ExternalCrate {
|
||||
crate crate_num: CrateNum,
|
||||
crate name: Symbol,
|
||||
crate src: FileName,
|
||||
crate attrs: Attributes,
|
||||
crate primitives: ThinVec<(DefId, PrimitiveType)>,
|
||||
crate keywords: ThinVec<(DefId, Symbol)>,
|
||||
}
|
||||
|
||||
impl ExternalCrate {
|
||||
crate fn src(&self, tcx: TyCtxt<'_>) -> FileName {
|
||||
let root = DefId { krate: self.crate_num, index: rustc_hir::def_id::CRATE_DEF_INDEX };
|
||||
let krate_span = tcx.def_span(root);
|
||||
tcx.sess.source_map().span_to_filename(krate_span)
|
||||
}
|
||||
}
|
||||
|
||||
/// Anything with a source location and set of attributes and, optionally, a
|
||||
/// name. That is, anything that can be documented. This doesn't correspond
|
||||
/// directly to the AST's concept of an item; it's a strict superset.
|
||||
|
|
|
@ -54,7 +54,9 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let ExternalCrate { name, src, primitives, keywords, .. } = LOCAL_CRATE.clean(cx);
|
||||
let local_crate = LOCAL_CRATE.clean(cx);
|
||||
let src = local_crate.src(cx.tcx);
|
||||
let ExternalCrate { name, primitives, keywords, .. } = local_crate;
|
||||
{
|
||||
let m = match *module.kind {
|
||||
ItemKind::ModuleItem(ref mut m) => m,
|
||||
|
|
|
@ -155,7 +155,7 @@ impl Cache {
|
|||
// Cache where all our extern crates are located
|
||||
// FIXME: this part is specific to HTML so it'd be nice to remove it from the common code
|
||||
for &(n, ref e) in &krate.externs {
|
||||
let src_root = match e.src {
|
||||
let src_root = match e.src(tcx) {
|
||||
FileName::Real(ref p) => match p.local_path().parent() {
|
||||
Some(p) => p.to_path_buf(),
|
||||
None => PathBuf::new(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue