about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWill Crichton <wcrichto@cs.stanford.edu>2021-12-11 10:13:16 -0800
committerWill Crichton <wcrichto@cs.stanford.edu>2021-12-11 10:13:16 -0800
commitb7de7973b221acb2ce900a04c11320a16fc884fb (patch)
tree8fcd1d310e5e65a9db8d0498c34df16ffc6c5f69
parentb9a37ad0d995c71518629b032f8e816e1efa8bca (diff)
downloadrust-b7de7973b221acb2ce900a04c11320a16fc884fb.tar.gz
rust-b7de7973b221acb2ce900a04c11320a16fc884fb.zip
Don't emit shared files when scraping dependencies
-rw-r--r--src/librustdoc/config.rs4
-rw-r--r--src/librustdoc/html/render/context.rs16
-rw-r--r--src/librustdoc/scrape_examples.rs3
3 files changed, 16 insertions, 7 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index ee19567be10..155bd324c39 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -282,7 +282,10 @@ crate struct RenderOptions {
     crate emit: Vec<EmitType>,
     /// If `true`, HTML source pages will generate links for items to their definition.
     crate generate_link_to_definition: bool,
+    /// Set of function-call locations to include as examples
     crate call_locations: AllCallLocations,
+    /// If `true`, Context::init will not emit shared files.
+    crate no_emit_shared: bool,
 }
 
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@@ -753,6 +756,7 @@ impl Options {
                 emit,
                 generate_link_to_definition,
                 call_locations,
+                no_emit_shared: false,
             },
             crate_name,
             output_format,
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 365d959ad9f..bae02bb7457 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -405,6 +405,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
             show_type_layout,
             generate_link_to_definition,
             call_locations,
+            no_emit_shared,
             ..
         } = options;
 
@@ -525,13 +526,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
             sources::render(&mut cx, &krate)?;
         }
 
-        // Build our search index
-        let index = build_index(&krate, &mut Rc::get_mut(&mut cx.shared).unwrap().cache, tcx);
+        if !no_emit_shared {
+            // Build our search index
+            let index = build_index(&krate, &mut Rc::get_mut(&mut cx.shared).unwrap().cache, tcx);
+
+            // Write shared runs within a flock; disable thread dispatching of IO temporarily.
+            Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
+            write_shared(&cx, &krate, index, &md_opts)?;
+            Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
+        }
 
-        // Write shared runs within a flock; disable thread dispatching of IO temporarily.
-        Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
-        write_shared(&cx, &krate, index, &md_opts)?;
-        Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
         Ok((cx, krate))
     }
 
diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs
index 10b6fdf87f4..6809551fcfd 100644
--- a/src/librustdoc/scrape_examples.rs
+++ b/src/librustdoc/scrape_examples.rs
@@ -223,13 +223,14 @@ where
 
 crate fn run(
     krate: clean::Crate,
-    renderopts: config::RenderOptions,
+    mut renderopts: config::RenderOptions,
     cache: formats::cache::Cache,
     tcx: TyCtxt<'_>,
     options: ScrapeExamplesOptions,
 ) -> interface::Result<()> {
     let inner = move || -> Result<(), String> {
         // Generates source files for examples
+        renderopts.no_emit_shared = true;
         let (cx, _) = Context::init(krate, renderopts, cache, tcx).map_err(|e| e.to_string())?;
 
         // Collect CrateIds corresponding to provided target crates