Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a6446c5
rustdoc: fix type search index for `fn<T>() -> &T where T: Trait`
notriddle Mar 7, 2023
44813e0
rustdoc: fix type search when more than one `where` clause applies
notriddle Mar 7, 2023
50f7520
rustdoc: DocFS: Replace rayon with threadpool and enable it for all t…
GuillaumeGomez Mar 14, 2023
e482701
Assert def-kind is correct for alias types
compiler-errors Mar 14, 2023
cf6424e
Don't make projection tys out of anon consts
compiler-errors Mar 14, 2023
bd17322
error-msg: impl better suggestion for `E0532`
Ezrashaw Mar 10, 2023
d3d537b
Exhaustively match over all alias kinds
oli-obk Mar 7, 2023
d87fbb9
Deduplicate logic between projection normalization with and without e…
oli-obk Mar 8, 2023
d2b7604
always make `define_opaque_types` explicit
lcnr Mar 15, 2023
5ad1083
Revert "Auto merge of #107376 - aliemjay:remove-givens, r=lcnr"
lqd Mar 15, 2023
e667872
Update docsfs module documentation
GuillaumeGomez Mar 15, 2023
6e1ab1d
mv tests/codegen/issue-* tests/codegen/issues/
scottmcm Mar 15, 2023
e5a5b90
unequal → not equal
Mar 15, 2023
683c12c
rustdoc: remove `std::` from primitive intra-doc link tooltips
notriddle Mar 15, 2023
7f3d88a
Rollup merge of #108875 - notriddle:notriddle/return-trait, r=Guillau…
matthiaskrgr Mar 15, 2023
c411d36
Rollup merge of #108971 - Ezrashaw:E0532-better-binding-names, r=Waff…
matthiaskrgr Mar 15, 2023
ead92dd
Rollup merge of #109139 - GuillaumeGomez:rustdoc-windows-wait-for-wri…
matthiaskrgr Mar 15, 2023
b62fe7a
Rollup merge of #109151 - compiler-errors:debug-assert-alias, r=Waffl…
matthiaskrgr Mar 15, 2023
8dac658
Rollup merge of #109166 - lcnr:define_opaque_types-explicit, r=oli-obk
matthiaskrgr Mar 15, 2023
ef22ccb
Rollup merge of #109171 - oli-obk:normalization_cleanup, r=compiler-e…
matthiaskrgr Mar 15, 2023
af5a737
Rollup merge of #109172 - scottmcm:move-codegen-issues-tests, r=Waffl…
matthiaskrgr Mar 15, 2023
6e76106
Rollup merge of #109180 - gimbles:master, r=compiler-errors
matthiaskrgr Mar 15, 2023
7805446
Rollup merge of #109183 - lqd:revert-107376, r=compiler-errors
matthiaskrgr Mar 15, 2023
a350c76
Rollup merge of #109185 - notriddle:notriddle/primitive-tooltip, r=jsha
matthiaskrgr Mar 15, 2023
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
11 changes: 10 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5458,13 +5458,13 @@ dependencies = [
"itertools",
"minifier",
"once_cell",
"rayon",
"regex",
"rustdoc-json-types",
"serde",
"serde_json",
"smallvec",
"tempfile",
"threadpool",
"tracing",
"tracing-subscriber",
"tracing-tree",
Expand Down Expand Up @@ -6209,6 +6209,15 @@ dependencies = [
"once_cell",
]

[[package]]
name = "threadpool"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
dependencies = [
"num_cpus",
]

[[package]]
name = "tidy"
version = "0.1.0"
Expand Down
4 changes: 1 addition & 3 deletions src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ smallvec = "1.8.1"
tempfile = "3"
tracing = "0.1"
tracing-tree = "0.2.0"
threadpool = "1.8.1"

[dependencies.tracing-subscriber]
version = "0.3.3"
default-features = false
features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"]

[target.'cfg(windows)'.dependencies]
rayon = "1.5.1"

[dev-dependencies]
expect-test = "1.4.0"

Expand Down
28 changes: 21 additions & 7 deletions src/librustdoc/docfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
//!
//! On Windows this indirects IO into threads to work around performance issues
//! with Defender (and other similar virus scanners that do blocking operations).
//! On other platforms this is a thin shim to fs.
//!
//! Only calls needed to permit this workaround have been abstracted: thus
//! fs::read is still done directly via the fs module; if in future rustdoc
//! needs to read-after-write from a file, then it would be added to this
//! abstraction.

use std::cmp::max;
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
use std::string::ToString;
use std::sync::mpsc::Sender;
use std::thread::available_parallelism;
use threadpool::ThreadPool;

pub(crate) trait PathError {
fn new<S, P: AsRef<Path>>(e: S, path: P) -> Self
Expand All @@ -24,11 +26,21 @@ pub(crate) trait PathError {
pub(crate) struct DocFS {
sync_only: bool,
errors: Option<Sender<String>>,
pool: ThreadPool,
}

impl DocFS {
pub(crate) fn new(errors: Sender<String>) -> DocFS {
DocFS { sync_only: false, errors: Some(errors) }
const MINIMUM_NB_THREADS: usize = 2;
DocFS {
sync_only: false,
errors: Some(errors),
pool: ThreadPool::new(
available_parallelism()
.map(|nb| max(nb.get(), MINIMUM_NB_THREADS))
.unwrap_or(MINIMUM_NB_THREADS),
),
}
}

pub(crate) fn set_sync_only(&mut self, sync_only: bool) {
Expand All @@ -54,12 +66,11 @@ impl DocFS {
where
E: PathError,
{
#[cfg(windows)]
if !self.sync_only {
// A possible future enhancement after more detailed profiling would
// be to create the file sync so errors are reported eagerly.
let sender = self.errors.clone().expect("can't write after closing");
rayon::spawn(move || {
self.pool.execute(move || {
fs::write(&path, contents).unwrap_or_else(|e| {
sender.send(format!("\"{}\": {}", path.display(), e)).unwrap_or_else(|_| {
panic!("failed to send error on \"{}\"", path.display())
Expand All @@ -70,9 +81,12 @@ impl DocFS {
fs::write(&path, contents).map_err(|e| E::new(e, path))?;
}

#[cfg(not(windows))]
fs::write(&path, contents).map_err(|e| E::new(e, path))?;

Ok(())
}
}

impl Drop for DocFS {
fn drop(&mut self) {
self.pool.join();
}
}