Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the dummy cache in DocContext; delete RenderInfo #82018

Merged
merged 3 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove krate.version; fix crate_version in JSON
Previously, `JsonRenderer::after_krate` called `krate.version.clone()`.
The problem was it did that after the version was already moved into the
cache, so it would always be None. The fix was to get the version from
the cache instead.
  • Loading branch information
jyn514 committed Mar 1, 2021
commit be069a687a4e1c231b8ae8c68ac0444fa6fee249
1 change: 0 additions & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ thread_local!(crate static MAX_DEF_IDX: RefCell<FxHashMap<CrateNum, DefIndex>> =
#[derive(Clone, Debug)]
crate struct Crate {
crate name: Symbol,
crate version: Option<String>,
camelid marked this conversation as resolved.
Show resolved Hide resolved
crate src: FileName,
crate module: Option<Item>,
crate externs: Vec<(CrateNum, ExternalCrate)>,
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {

Crate {
name,
version: None,
src,
module: Some(module),
externs,
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ impl Cache {
dst: &Path,
) -> clean::Crate {
// Crawl the crate to build various caches used for the output
self.crate_version = krate.version.take();
debug!(?self.crate_version);
jyn514 marked this conversation as resolved.
Show resolved Hide resolved
self.traits = krate.external_traits.take();
self.masked_crates = mem::take(&mut krate.masked_crates);
camelid marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {

fn after_krate(
&mut self,
krate: &clean::Crate,
_krate: &clean::Crate,
_diag: &rustc_errors::Handler,
) -> Result<(), Error> {
debug!("Done with crate");
Expand All @@ -210,7 +210,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
#[allow(rustc::default_hash_types)]
let output = types::Crate {
root: types::Id(String::from("0:0")),
crate_version: krate.version.clone(),
crate_version: self.cache.crate_version.clone(),
includes_private: self.cache.document_private,
index: index.into_iter().collect(),
paths: self
Expand Down
4 changes: 3 additions & 1 deletion src/test/rustdoc-json/nested.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// edition:2018
// compile-flags: --crate-version 1.0.0

// @is nested.json "$.index[*][?(@.name=='nested')].kind" \"module\"
// @is nested.json "$.crate_version" \"1.0.0\"
// @is - "$.index[*][?(@.name=='nested')].kind" \"module\"
// @is - "$.index[*][?(@.name=='nested')].inner.is_crate" true
// @count - "$.index[*][?(@.name=='nested')].inner.items[*]" 1

Expand Down