Skip to content

Commit b7de797

Browse files
committed
Don't emit shared files when scraping dependencies
1 parent b9a37ad commit b7de797

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/librustdoc/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ crate struct RenderOptions {
282282
crate emit: Vec<EmitType>,
283283
/// If `true`, HTML source pages will generate links for items to their definition.
284284
crate generate_link_to_definition: bool,
285+
/// Set of function-call locations to include as examples
285286
crate call_locations: AllCallLocations,
287+
/// If `true`, Context::init will not emit shared files.
288+
crate no_emit_shared: bool,
286289
}
287290

288291
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@@ -753,6 +756,7 @@ impl Options {
753756
emit,
754757
generate_link_to_definition,
755758
call_locations,
759+
no_emit_shared: false,
756760
},
757761
crate_name,
758762
output_format,

src/librustdoc/html/render/context.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
405405
show_type_layout,
406406
generate_link_to_definition,
407407
call_locations,
408+
no_emit_shared,
408409
..
409410
} = options;
410411

@@ -525,13 +526,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
525526
sources::render(&mut cx, &krate)?;
526527
}
527528

528-
// Build our search index
529-
let index = build_index(&krate, &mut Rc::get_mut(&mut cx.shared).unwrap().cache, tcx);
529+
if !no_emit_shared {
530+
// Build our search index
531+
let index = build_index(&krate, &mut Rc::get_mut(&mut cx.shared).unwrap().cache, tcx);
532+
533+
// Write shared runs within a flock; disable thread dispatching of IO temporarily.
534+
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
535+
write_shared(&cx, &krate, index, &md_opts)?;
536+
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
537+
}
530538

531-
// Write shared runs within a flock; disable thread dispatching of IO temporarily.
532-
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
533-
write_shared(&cx, &krate, index, &md_opts)?;
534-
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
535539
Ok((cx, krate))
536540
}
537541

src/librustdoc/scrape_examples.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,14 @@ where
223223

224224
crate fn run(
225225
krate: clean::Crate,
226-
renderopts: config::RenderOptions,
226+
mut renderopts: config::RenderOptions,
227227
cache: formats::cache::Cache,
228228
tcx: TyCtxt<'_>,
229229
options: ScrapeExamplesOptions,
230230
) -> interface::Result<()> {
231231
let inner = move || -> Result<(), String> {
232232
// Generates source files for examples
233+
renderopts.no_emit_shared = true;
233234
let (cx, _) = Context::init(krate, renderopts, cache, tcx).map_err(|e| e.to_string())?;
234235

235236
// Collect CrateIds corresponding to provided target crates

0 commit comments

Comments
 (0)