Skip to content

Commit 6fb8d9f

Browse files
committed
rustdoc: avoid loading index when user says no
1 parent 38a2a3d commit 6fb8d9f

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/librustdoc/html/render/search_index.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use tracing::instrument;
2424

2525
use crate::clean::types::{Function, Generics, ItemId, Type, WherePredicate};
2626
use crate::clean::{self, utils};
27+
use crate::config::ShouldMerge;
2728
use crate::error::Error;
2829
use crate::formats::cache::{Cache, OrphanImplItem};
2930
use crate::formats::item_type::ItemType;
@@ -722,11 +723,7 @@ impl SerializedSearchIndex {
722723
},
723724
),
724725
self.alias_pointers[id].and_then(|alias| {
725-
if self.names[alias].is_empty() {
726-
None
727-
} else {
728-
map.get(&alias).copied()
729-
}
726+
if self.names[alias].is_empty() { None } else { map.get(&alias).copied() }
730727
}),
731728
);
732729
}
@@ -1254,6 +1251,7 @@ pub(crate) fn build_index(
12541251
tcx: TyCtxt<'_>,
12551252
doc_root: &Path,
12561253
resource_suffix: &str,
1254+
should_merge: &ShouldMerge,
12571255
) -> Result<SerializedSearchIndex, Error> {
12581256
let mut search_index = std::mem::take(&mut cache.search_index);
12591257

@@ -1304,7 +1302,11 @@ pub(crate) fn build_index(
13041302
//
13051303
// if there's already a search index, load it into memory and add the new entries to it
13061304
// otherwise, do nothing
1307-
let mut serialized_index = SerializedSearchIndex::load(doc_root, resource_suffix)?;
1305+
let mut serialized_index = if should_merge.read_rendered_cci {
1306+
SerializedSearchIndex::load(doc_root, resource_suffix)?
1307+
} else {
1308+
SerializedSearchIndex::default()
1309+
};
13081310

13091311
// The crate always goes first in this list
13101312
let crate_name = krate.name(tcx);

src/librustdoc/html/render/write_shared.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@ pub(crate) fn write_shared(
6666
// Write shared runs within a flock; disable thread dispatching of IO temporarily.
6767
let _lock = try_err!(flock::Lock::new(&lock_file, true, true, true), &lock_file);
6868

69-
let search_index =
70-
build_index(krate, &mut cx.shared.cache, tcx, &cx.dst, &cx.shared.resource_suffix)?;
69+
let search_index = build_index(
70+
krate,
71+
&mut cx.shared.cache,
72+
tcx,
73+
&cx.dst,
74+
&cx.shared.resource_suffix,
75+
&opt.should_merge,
76+
)?;
7177

7278
let crate_name = krate.name(cx.tcx());
7379
let crate_name = crate_name.as_str(); // rand

0 commit comments

Comments
 (0)