diff options
| author | Noah Lev <camelidcamel@gmail.com> | 2021-10-28 20:55:02 -0700 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2021-10-30 11:16:24 -0700 |
| commit | ebe9a11f71f2998e0be4d9b95f4eac5d1e1f82a0 (patch) | |
| tree | d1c502e2e8b21149a426315976348c8324c84369 /src/librustdoc/html/render/write_shared.rs | |
| parent | 85f8ae8ec49683df08a598b0f2594dd066f24a11 (diff) | |
| download | rust-ebe9a11f71f2998e0be4d9b95f4eac5d1e1f82a0.tar.gz rust-ebe9a11f71f2998e0be4d9b95f4eac5d1e1f82a0.zip | |
rustdoc: Remove `Crate.name` and instead compute it on-demand
It is not as large as `Crate.src` was, but it's still 8 bytes, and `clean::Crate` is moved by-value a lot.
Diffstat (limited to 'src/librustdoc/html/render/write_shared.rs')
| -rw-r--r-- | src/librustdoc/html/render/write_shared.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 34f1b4cd684..08f4435c45c 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -455,10 +455,10 @@ pub(super) fn write_shared( let dst = cx.dst.join(&format!("source-files{}.js", cx.shared.resource_suffix)); let make_sources = || { let (mut all_sources, _krates) = - try_err!(collect(&dst, &krate.name.as_str(), "sourcesIndex"), &dst); + try_err!(collect(&dst, &krate.name(cx.tcx()).as_str(), "sourcesIndex"), &dst); all_sources.push(format!( "sourcesIndex[\"{}\"] = {};", - &krate.name, + &krate.name(cx.tcx()), hierarchy.to_json_string() )); all_sources.sort(); @@ -473,9 +473,10 @@ pub(super) fn write_shared( // Update the search index and crate list. let dst = cx.dst.join(&format!("search-index{}.js", cx.shared.resource_suffix)); - let (mut all_indexes, mut krates) = try_err!(collect_json(&dst, &krate.name.as_str()), &dst); + let (mut all_indexes, mut krates) = + try_err!(collect_json(&dst, &krate.name(cx.tcx()).as_str()), &dst); all_indexes.push(search_index); - krates.push(krate.name.to_string()); + krates.push(krate.name(cx.tcx()).to_string()); krates.sort(); // Sort the indexes by crate so the file will be generated identically even @@ -599,7 +600,7 @@ pub(super) fn write_shared( let implementors = format!( r#"implementors["{}"] = {};"#, - krate.name, + krate.name(cx.tcx()), serde_json::to_string(&implementors).unwrap() ); @@ -611,7 +612,7 @@ pub(super) fn write_shared( mydst.push(&format!("{}.{}.js", remote_item_type, remote_path[remote_path.len() - 1])); let (mut all_implementors, _) = - try_err!(collect(&mydst, &krate.name.as_str(), "implementors"), &mydst); + try_err!(collect(&mydst, &krate.name(cx.tcx()).as_str(), "implementors"), &mydst); all_implementors.push(implementors); // Sort the implementors by crate so the file will be generated // identically even with rustdoc running in parallel. |
