Skip to content

Commit 2f92f05

Browse files
committedFeb 6, 2025
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 #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" ( #113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2 parents 5958825 + 0a21f1d commit 2f92f05

File tree

77 files changed

+405
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+405
-395
lines changed
 

‎compiler/rustc_ast/src/ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
2020
2121
use std::borrow::Cow;
22+
use std::sync::Arc;
2223
use std::{cmp, fmt};
2324

2425
pub use GenericArgs::*;
@@ -27,7 +28,6 @@ pub use rustc_ast_ir::{Movability, Mutability, Pinnedness};
2728
use rustc_data_structures::packed::Pu128;
2829
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2930
use rustc_data_structures::stack::ensure_sufficient_stack;
30-
use rustc_data_structures::sync::Lrc;
3131
use rustc_data_structures::tagged_ptr::Tag;
3232
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3333
pub use rustc_span::AttrId;
@@ -1611,7 +1611,7 @@ pub enum ExprKind {
16111611
/// Added for optimization purposes to avoid the need to escape
16121612
/// large binary blobs - should always behave like [`ExprKind::Lit`]
16131613
/// with a `ByteStr` literal.
1614-
IncludedBytes(Lrc<[u8]>),
1614+
IncludedBytes(Arc<[u8]>),
16151615

16161616
/// A `format_args!()` expression.
16171617
FormatArgs(P<FormatArgs>),
@@ -1904,9 +1904,9 @@ pub enum LitKind {
19041904
Str(Symbol, StrStyle),
19051905
/// A byte string (`b"foo"`). Not stored as a symbol because it might be
19061906
/// non-utf8, and symbols only allow utf8 strings.
1907-
ByteStr(Lrc<[u8]>, StrStyle),
1907+
ByteStr(Arc<[u8]>, StrStyle),
19081908
/// A C String (`c"foo"`). Guaranteed to only have `\0` at the end.
1909-
CStr(Lrc<[u8]>, StrStyle),
1909+
CStr(Arc<[u8]>, StrStyle),
19101910
/// A byte char (`b'f'`).
19111911
Byte(u8),
19121912
/// A character literal (`'a'`).

‎compiler/rustc_ast/src/mut_visit.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
1010
use std::ops::DerefMut;
1111
use std::panic;
12+
use std::sync::Arc;
1213

1314
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1415
use rustc_data_structures::stack::ensure_sufficient_stack;
15-
use rustc_data_structures::sync::Lrc;
1616
use rustc_span::source_map::Spanned;
1717
use rustc_span::{Ident, Span};
1818
use smallvec::{Array, SmallVec, smallvec};
@@ -793,14 +793,14 @@ fn visit_tt<T: MutVisitor>(vis: &mut T, tt: &mut TokenTree) {
793793
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
794794
fn visit_tts<T: MutVisitor>(vis: &mut T, TokenStream(tts): &mut TokenStream) {
795795
if T::VISIT_TOKENS && !tts.is_empty() {
796-
let tts = Lrc::make_mut(tts);
796+
let tts = Arc::make_mut(tts);
797797
visit_vec(tts, |tree| visit_tt(vis, tree));
798798
}
799799
}
800800

801801
fn visit_attr_tts<T: MutVisitor>(vis: &mut T, AttrTokenStream(tts): &mut AttrTokenStream) {
802802
if T::VISIT_TOKENS && !tts.is_empty() {
803-
let tts = Lrc::make_mut(tts);
803+
let tts = Arc::make_mut(tts);
804804
visit_vec(tts, |tree| visit_attr_tt(vis, tree));
805805
}
806806
}
@@ -840,7 +840,7 @@ pub fn visit_token<T: MutVisitor>(vis: &mut T, t: &mut Token) {
840840
vis.visit_ident(ident);
841841
}
842842
token::Interpolated(nt) => {
843-
let nt = Lrc::make_mut(nt);
843+
let nt = Arc::make_mut(nt);
844844
visit_nonterminal(vis, nt);
845845
}
846846
_ => {}

0 commit comments

Comments
 (0)