Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7735917

Browse files
authoredAug 15, 2024··
Unrolled build for rust-lang#129124
Rollup merge of rust-lang#129124 - aDotInTheVoid:rdj-hashmap-3, r=GuillaumeGomez rustdoc-json: Use FxHashMap from rustdoc_json_types Alternative to rust-lang#110051 and rust-lang#127456. This lets us avoid rehashing the json index after building it by using the same hashmap type in construction and in rustdoc_json_types. The above PR's tried to do this by having rustdoc_json_types get the same hashmap that rustdoc has via rustc_data_structures. However, this can be made simpler if we change rustdoc instead. For the rustdoc-type republish on crates.io, It will filter out the `pub use`, and not change source at all. rust-lang/rustdoc-types#30. That code [already replaces the hashmap](https://github.com/aDotInTheVoid/rustdoc-types/blob/8d6528669ec64c2af43d1c79a228b7711cefdad7/update.sh#L11) to use the one in `std::collections` (instead of `FxHashMap`) try-job: dist-arm-linux r? ``@GuillaumeGomez``
2 parents d2b5aa6 + 9028b53 commit 7735917

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎src/librustdoc/json/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ use std::io::{stdout, BufWriter, Write};
1313
use std::path::PathBuf;
1414
use std::rc::Rc;
1515

16-
use rustc_data_structures::fx::FxHashMap;
1716
use rustc_hir::def_id::{DefId, DefIdSet};
1817
use rustc_middle::ty::TyCtxt;
1918
use rustc_session::Session;
2019
use rustc_span::def_id::LOCAL_CRATE;
2120
use rustdoc_json_types as types;
21+
// It's important to use the FxHashMap from rustdoc_json_types here, instead of
22+
// the one from rustc_data_structures, as they're different types due to sysroots.
23+
// See #110051 and #127456 for details
24+
use rustdoc_json_types::FxHashMap;
2225

2326
use crate::clean::types::{ExternalCrate, ExternalLocation};
2427
use crate::clean::ItemKind;
@@ -234,14 +237,11 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
234237
let index = (*self.index).clone().into_inner();
235238

236239
debug!("Constructing Output");
237-
// This needs to be the default HashMap for compatibility with the public interface for
238-
// rustdoc-json-types
239-
#[allow(rustc::default_hash_types)]
240240
let output = types::Crate {
241241
root: types::Id(format!("0:0:{}", e.name(self.tcx).as_u32())),
242242
crate_version: self.cache.crate_version.clone(),
243243
includes_private: self.cache.document_private,
244-
index: index.into_iter().collect(),
244+
index,
245245
paths: self
246246
.cache
247247
.paths

‎src/rustdoc-json-types/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
use std::path::PathBuf;
77

8-
use rustc_hash::FxHashMap;
8+
pub use rustc_hash::FxHashMap;
99
use serde::{Deserialize, Serialize};
1010

1111
/// The version of JSON output that this crate represents.

0 commit comments

Comments
 (0)
Please sign in to comment.