diff options
| author | bors <bors@rust-lang.org> | 2023-03-16 11:06:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-03-16 11:06:02 +0000 |
| commit | 7ac4b82ddd596a218cac8cd6b88a91b54fcdcf13 (patch) | |
| tree | 191fd952f333b9275766d48bab742a4208ec6ad4 /src | |
| parent | cd6c574af3886c41f34086d90df42c3da0144693 (diff) | |
| parent | a70e138ed89fe5464bb372410c8418058783b9cc (diff) | |
| download | rust-7ac4b82ddd596a218cac8cd6b88a91b54fcdcf13.tar.gz rust-7ac4b82ddd596a218cac8cd6b88a91b54fcdcf13.zip | |
Auto merge of #109206 - matthiaskrgr:rollup-oev8ax6, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #108875 (rustdoc: fix type search for `Option` combinators) - #108971 (error-msg: impl better suggestion for `E0532`) - #109139 (rustdoc: DocFS: Replace rayon with threadpool and enable it for all targets) - #109151 (Assert def-kind is correct for alias types) - #109158 (error-msg: expand suggestion for `unused_def` lint) - #109166 (make `define_opaque_types` fully explicit) - #109171 (Some cleanups in our normalization logic) - #109180 (Unequal → Not equal) - #109185 (rustdoc: remove `std::` from primitive intra-doc link tooltips) - #109192 (Mention UEFI target promotion in release notes for 1.67.0) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/Cargo.toml | 4 | ||||
| -rw-r--r-- | src/librustdoc/clean/blanket_impl.rs | 5 | ||||
| -rw-r--r-- | src/librustdoc/docfs.rs | 28 | ||||
| -rw-r--r-- | src/librustdoc/html/format.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/html/render/search_index.rs | 9 |
5 files changed, 37 insertions, 15 deletions
diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 6ca6edfd3c9..29912b95703 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -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" diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index bcdbbcacc4b..3a3bf6a7ab9 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -1,6 +1,6 @@ use crate::rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; use rustc_hir as hir; -use rustc_infer::infer::{InferOk, TyCtxtInferExt}; +use rustc_infer::infer::{DefineOpaqueTypes, InferOk, TyCtxtInferExt}; use rustc_infer::traits; use rustc_middle::ty::ToPredicate; use rustc_span::DUMMY_SP; @@ -47,8 +47,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> { // Require the type the impl is implemented on to match // our type, and ignore the impl if there was a mismatch. - let cause = traits::ObligationCause::dummy(); - let Ok(eq_result) = infcx.at(&cause, param_env).eq(impl_trait_ref.self_ty(), impl_ty) else { + let Ok(eq_result) = infcx.at(&traits::ObligationCause::dummy(), param_env).eq(DefineOpaqueTypes::No, impl_trait_ref.self_ty(), impl_ty) else { continue }; let InferOk { value: (), obligations } = eq_result; diff --git a/src/librustdoc/docfs.rs b/src/librustdoc/docfs.rs index be066bdafa1..d58b8dc6ad4 100644 --- a/src/librustdoc/docfs.rs +++ b/src/librustdoc/docfs.rs @@ -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 @@ -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) { @@ -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()) @@ -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(); + } +} diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 024ea62c31a..27010b771d3 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -771,6 +771,12 @@ pub(crate) fn link_tooltip(did: DefId, fragment: &Option<UrlFragment>, cx: &Cont .or_else(|| cache.external_paths.get(&did)) else { return String::new() }; let mut buf = Buffer::new(); + let fqp = if *shortty == ItemType::Primitive { + // primitives are documented in a crate, but not actually part of it + &fqp[fqp.len() - 1..] + } else { + &fqp + }; if let &Some(UrlFragment::Item(id)) = fragment { write!(buf, "{} ", cx.tcx().def_descr(id)); for component in fqp { diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 146221f5806..08a0e1c377e 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -486,7 +486,7 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>( } // First, check if it's "Self". - let arg = if let Some(self_) = self_ { + let mut arg = if let Some(self_) = self_ { match &*arg { Type::BorrowedRef { type_, .. } if type_.is_self_type() => self_, type_ if type_.is_self_type() => self_, @@ -496,11 +496,16 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>( arg }; + // strip references from the argument type + while let Type::BorrowedRef { type_, .. } = &*arg { + arg = &*type_; + } + // If this argument is a type parameter and not a trait bound or a type, we need to look // for its bounds. if let Type::Generic(arg_s) = *arg { // First we check if the bounds are in a `where` predicate... - if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g { + for where_pred in generics.where_predicates.iter().filter(|g| match g { WherePredicate::BoundPredicate { ty: Type::Generic(ty_s), .. } => *ty_s == arg_s, _ => false, }) { |
