Skip to content

Commit 3bef65f

Browse files
committed
Remove name field from ExternalCrate
1 parent 5407a69 commit 3bef65f

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

src/librustdoc/clean/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ impl Clean<ExternalCrate> for CrateNum {
194194

195195
ExternalCrate {
196196
crate_num: *self,
197-
name: tcx.crate_name(*self),
198197
attrs: tcx.get_attrs(root).clean(cx),
199198
primitives,
200199
keywords,

src/librustdoc/clean/types.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ crate struct TraitWithExtraInfo {
7373
#[derive(Clone, Debug)]
7474
crate struct ExternalCrate {
7575
crate crate_num: CrateNum,
76-
crate name: Symbol,
7776
crate attrs: Attributes,
7877
crate primitives: ThinVec<(DefId, PrimitiveType)>,
7978
crate keywords: ThinVec<(DefId, Symbol)>,
@@ -85,6 +84,10 @@ impl ExternalCrate {
8584
let krate_span = tcx.def_span(root);
8685
tcx.sess.source_map().span_to_filename(krate_span)
8786
}
87+
88+
crate fn name(&self, tcx: TyCtxt<'_>) -> Symbol {
89+
tcx.crate_name(self.crate_num)
90+
}
8891
}
8992

9093
/// Anything with a source location and set of attributes and, optionally, a

src/librustdoc/clean/utils.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
5656

5757
let local_crate = LOCAL_CRATE.clean(cx);
5858
let src = local_crate.src(cx.tcx);
59-
let ExternalCrate { name, primitives, keywords, .. } = local_crate;
59+
let name = local_crate.name(cx.tcx);
60+
let ExternalCrate { primitives, keywords, .. } = local_crate;
6061
{
6162
let m = match *module.kind {
6263
ItemKind::ModuleItem(ref mut m) => m,

src/librustdoc/formats/cache.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,13 @@ impl Cache {
162162
},
163163
_ => PathBuf::new(),
164164
};
165-
let extern_url = extern_html_root_urls.get(&*e.name.as_str()).map(|u| &**u);
165+
let name = e.name(tcx);
166+
let extern_url = extern_html_root_urls.get(&*name.as_str()).map(|u| &**u);
166167
self.extern_locations
167-
.insert(n, (e.name, src_root, extern_location(e, extern_url, &dst)));
168+
.insert(n, (name, src_root, extern_location(e, extern_url, &dst, tcx)));
168169

169170
let did = DefId { krate: n, index: CRATE_DEF_INDEX };
170-
self.external_paths.insert(did, (vec![e.name.to_string()], ItemType::Module));
171+
self.external_paths.insert(did, (vec![name.to_string()], ItemType::Module));
171172
}
172173

173174
// Cache where all known primitives have their documentation located.

src/librustdoc/html/render/cache.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ crate fn extern_location(
3131
e: &clean::ExternalCrate,
3232
extern_url: Option<&str>,
3333
dst: &Path,
34+
tcx: TyCtxt<'_>,
3435
) -> ExternalLocation {
3536
use ExternalLocation::*;
3637
// See if there's documentation generated into the local directory
37-
let local_location = dst.join(&*e.name.as_str());
38+
let local_location = dst.join(&*e.name(tcx).as_str());
3839
if local_location.is_dir() {
3940
return Local;
4041
}

0 commit comments

Comments
 (0)