diff options
| author | bors <bors@rust-lang.org> | 2025-02-06 10:50:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-02-06 10:50:05 +0000 |
| commit | 2f92f050e83bf3312ce4ba73c31fe843ad3cbc60 (patch) | |
| tree | ce6f75039ccafd2fa1dd5dbdeeff37233cb09d45 /src/librustdoc | |
| parent | 59588250ad973ce69bd15879314c9769e65f36b3 (diff) | |
| parent | 0a21f1d0a2fe9e84727a2de735fdcf55e8820db6 (diff) | |
| download | rust-2f92f050e83bf3312ce4ba73c31fe843ad3cbc60.tar.gz rust-2f92f050e83bf3312ce4ba73c31fe843ad3cbc60.zip | |
Auto merge of #136471 - safinaskar:parallel, r=SparrowLii
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`
This is continuation of https://github.com/rust-lang/rust/pull/132282 .
I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement.
There are other possibilities, through.
We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase.
So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge.
cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 )
r? SparrowLii
`@rustbot` label WG-compiler-parallel
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/core.rs | 7 | ||||
| -rw-r--r-- | src/librustdoc/doctest/make.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/doctest/rust.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/passes/lint/check_code_block_syntax.rs | 12 |
4 files changed, 15 insertions, 14 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 6af35157a43..5c146da03ac 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -1,8 +1,7 @@ -use std::sync::LazyLock; +use std::sync::{Arc, LazyLock}; use std::{io, mem}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; -use rustc_data_structures::sync::Lrc; use rustc_data_structures::unord::UnordSet; use rustc_driver::USING_INTERNAL_FEATURES; use rustc_errors::TerminalUrl; @@ -145,7 +144,7 @@ impl<'tcx> DocContext<'tcx> { /// will be created for the `DiagCtxt`. pub(crate) fn new_dcx( error_format: ErrorOutputType, - source_map: Option<Lrc<source_map::SourceMap>>, + source_map: Option<Arc<source_map::SourceMap>>, diagnostic_width: Option<usize>, unstable_opts: &UnstableOptions, ) -> rustc_errors::DiagCtxt { @@ -173,7 +172,7 @@ pub(crate) fn new_dcx( } ErrorOutputType::Json { pretty, json_rendered, color_config } => { let source_map = source_map.unwrap_or_else(|| { - Lrc::new(source_map::SourceMap::new(source_map::FilePathMapping::empty())) + Arc::new(source_map::SourceMap::new(source_map::FilePathMapping::empty())) }); Box::new( JsonEmitter::new( diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index 7bcb9465948..d89caabefe3 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -2,9 +2,9 @@ //! runnable, e.g. by adding a `main` function if it doesn't already exist. use std::io; +use std::sync::Arc; use rustc_ast as ast; -use rustc_data_structures::sync::Lrc; use rustc_errors::emitter::stderr_destination; use rustc_errors::{ColorConfig, FatalError}; use rustc_parse::new_parser_from_source_str; @@ -280,7 +280,7 @@ fn parse_source( // Any errors in parsing should also appear when the doctest is compiled for real, so just // send all the errors that librustc_ast emits directly into a `Sink` instead of stderr. - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); + let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let fallback_bundle = rustc_errors::fallback_fluent_bundle( rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false, @@ -474,7 +474,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> Option<AttrKind> let filename = FileName::anon_source_code(source); // Any errors in parsing should also appear when the doctest is compiled for real, so just // send all the errors that librustc_ast emits directly into a `Sink` instead of stderr. - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); + let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let fallback_bundle = rustc_errors::fallback_fluent_bundle( rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false, diff --git a/src/librustdoc/doctest/rust.rs b/src/librustdoc/doctest/rust.rs index bd292efeb7e..c4956bfd2b4 100644 --- a/src/librustdoc/doctest/rust.rs +++ b/src/librustdoc/doctest/rust.rs @@ -1,9 +1,9 @@ //! Doctest functionality used only for doctests in `.rs` source files. use std::env; +use std::sync::Arc; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::sync::Lrc; use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId}; use rustc_hir::{self as hir, CRATE_HIR_ID, intravisit}; use rustc_middle::hir::nested_filter; @@ -17,7 +17,7 @@ use crate::clean::{Attributes, extract_cfg_from_attrs}; use crate::html::markdown::{self, ErrorCodes, LangString, MdRelLine}; struct RustCollector { - source_map: Lrc<SourceMap>, + source_map: Arc<SourceMap>, tests: Vec<ScrapedDocTest>, cur_path: Vec<String>, position: Span, diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index d9c277c047f..459bdd991db 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -1,6 +1,8 @@ //! Validates syntax inside Rust code blocks (\`\`\`rust). -use rustc_data_structures::sync::{Lock, Lrc}; +use std::sync::Arc; + +use rustc_data_structures::sync::Lock; use rustc_errors::emitter::Emitter; use rustc_errors::registry::Registry; use rustc_errors::translation::{Translate, to_fluent_args}; @@ -32,14 +34,14 @@ fn check_rust_syntax( dox: &str, code_block: RustCodeBlock, ) { - let buffer = Lrc::new(Lock::new(Buffer::default())); + let buffer = Arc::new(Lock::new(Buffer::default())); let fallback_bundle = rustc_errors::fallback_fluent_bundle( rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false, ); - let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle }; + let emitter = BufferEmitter { buffer: Arc::clone(&buffer), fallback_bundle }; - let sm = Lrc::new(SourceMap::new(FilePathMapping::empty())); + let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); let dcx = DiagCtxt::new(Box::new(emitter)).disable_warnings(); let source = dox[code_block.code].to_owned(); let psess = ParseSess::with_dcx(dcx, sm); @@ -141,7 +143,7 @@ struct Buffer { } struct BufferEmitter { - buffer: Lrc<Lock<Buffer>>, + buffer: Arc<Lock<Buffer>>, fallback_bundle: LazyFallbackBundle, } |
