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
This commit is contained in:
commit
2f92f050e8
77 changed files with 405 additions and 395 deletions
|
@ -6,6 +6,7 @@
|
|||
//! Imports are also considered items and placed into modules here, but not resolved yet.
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind};
|
||||
use rustc_ast::{
|
||||
|
@ -13,7 +14,6 @@ use rustc_ast::{
|
|||
ItemKind, MetaItemKind, NodeId, StmtKind,
|
||||
};
|
||||
use rustc_attr_parsing as attr;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_expand::base::ResolverExpand;
|
||||
use rustc_expand::expand::AstFragment;
|
||||
use rustc_hir::def::{self, *};
|
||||
|
@ -179,7 +179,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
LoadedMacro::MacroDef { def, ident, attrs, span, edition } => {
|
||||
self.compile_macro(&def, ident, &attrs, span, ast::DUMMY_NODE_ID, edition)
|
||||
}
|
||||
LoadedMacro::ProcMacro(ext) => MacroData::new(Lrc::new(ext)),
|
||||
LoadedMacro::ProcMacro(ext) => MacroData::new(Arc::new(ext)),
|
||||
};
|
||||
|
||||
self.macro_map.entry(def_id).or_insert(macro_data)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
||||
use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion};
|
||||
use effective_visibilities::EffectiveVisibilitiesVisitor;
|
||||
|
@ -46,7 +47,7 @@ use rustc_ast::{
|
|||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::steal::Steal;
|
||||
use rustc_data_structures::sync::{FreezeReadGuard, Lrc};
|
||||
use rustc_data_structures::sync::FreezeReadGuard;
|
||||
use rustc_errors::{Applicability, Diag, ErrCode, ErrorGuaranteed};
|
||||
use rustc_expand::base::{DeriveResolution, SyntaxExtension, SyntaxExtensionKind};
|
||||
use rustc_feature::BUILTIN_ATTRIBUTES;
|
||||
|
@ -995,13 +996,13 @@ struct DeriveData {
|
|||
}
|
||||
|
||||
struct MacroData {
|
||||
ext: Lrc<SyntaxExtension>,
|
||||
ext: Arc<SyntaxExtension>,
|
||||
rule_spans: Vec<(usize, Span)>,
|
||||
macro_rules: bool,
|
||||
}
|
||||
|
||||
impl MacroData {
|
||||
fn new(ext: Lrc<SyntaxExtension>) -> MacroData {
|
||||
fn new(ext: Arc<SyntaxExtension>) -> MacroData {
|
||||
MacroData { ext, rule_spans: Vec::new(), macro_rules: false }
|
||||
}
|
||||
}
|
||||
|
@ -1110,8 +1111,8 @@ pub struct Resolver<'ra, 'tcx> {
|
|||
registered_tools: &'tcx RegisteredTools,
|
||||
macro_use_prelude: FxHashMap<Symbol, NameBinding<'ra>>,
|
||||
macro_map: FxHashMap<DefId, MacroData>,
|
||||
dummy_ext_bang: Lrc<SyntaxExtension>,
|
||||
dummy_ext_derive: Lrc<SyntaxExtension>,
|
||||
dummy_ext_bang: Arc<SyntaxExtension>,
|
||||
dummy_ext_derive: Arc<SyntaxExtension>,
|
||||
non_macro_attr: MacroData,
|
||||
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
|
||||
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
|
||||
|
@ -1510,9 +1511,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
registered_tools,
|
||||
macro_use_prelude: FxHashMap::default(),
|
||||
macro_map: FxHashMap::default(),
|
||||
dummy_ext_bang: Lrc::new(SyntaxExtension::dummy_bang(edition)),
|
||||
dummy_ext_derive: Lrc::new(SyntaxExtension::dummy_derive(edition)),
|
||||
non_macro_attr: MacroData::new(Lrc::new(SyntaxExtension::non_macro_attr(edition))),
|
||||
dummy_ext_bang: Arc::new(SyntaxExtension::dummy_bang(edition)),
|
||||
dummy_ext_derive: Arc::new(SyntaxExtension::dummy_derive(edition)),
|
||||
non_macro_attr: MacroData::new(Arc::new(SyntaxExtension::non_macro_attr(edition))),
|
||||
invocation_parent_scopes: Default::default(),
|
||||
output_macro_rules_scopes: Default::default(),
|
||||
macro_rules_scopes: Default::default(),
|
||||
|
@ -1688,11 +1689,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
CStore::from_tcx(self.tcx)
|
||||
}
|
||||
|
||||
fn dummy_ext(&self, macro_kind: MacroKind) -> Lrc<SyntaxExtension> {
|
||||
fn dummy_ext(&self, macro_kind: MacroKind) -> Arc<SyntaxExtension> {
|
||||
match macro_kind {
|
||||
MacroKind::Bang => Lrc::clone(&self.dummy_ext_bang),
|
||||
MacroKind::Derive => Lrc::clone(&self.dummy_ext_derive),
|
||||
MacroKind::Attr => Lrc::clone(&self.non_macro_attr.ext),
|
||||
MacroKind::Bang => Arc::clone(&self.dummy_ext_bang),
|
||||
MacroKind::Derive => Arc::clone(&self.dummy_ext_derive),
|
||||
MacroKind::Attr => Arc::clone(&self.non_macro_attr.ext),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_ast::attr::AttributeExt;
|
||||
use rustc_ast::expand::StrippedCfgItem;
|
||||
|
@ -10,7 +11,6 @@ use rustc_ast::{self as ast, Crate, NodeId, attr};
|
|||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr_parsing::StabilityLevel;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{Applicability, StashKey};
|
||||
use rustc_expand::base::{
|
||||
DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, SyntaxExtensionKind,
|
||||
|
@ -239,7 +239,7 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
|
|||
invoc: &Invocation,
|
||||
eager_expansion_root: LocalExpnId,
|
||||
force: bool,
|
||||
) -> Result<Lrc<SyntaxExtension>, Indeterminate> {
|
||||
) -> Result<Arc<SyntaxExtension>, Indeterminate> {
|
||||
let invoc_id = invoc.expansion_data.id;
|
||||
let parent_scope = match self.invocation_parent_scopes.get(&invoc_id) {
|
||||
Some(parent_scope) => *parent_scope,
|
||||
|
@ -529,7 +529,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
force: bool,
|
||||
deleg_impl: Option<LocalDefId>,
|
||||
invoc_in_mod_inert_attr: Option<LocalDefId>,
|
||||
) -> Result<(Lrc<SyntaxExtension>, Res), Indeterminate> {
|
||||
) -> Result<(Arc<SyntaxExtension>, Res), Indeterminate> {
|
||||
let (ext, res) = match self.resolve_macro_or_delegation_path(
|
||||
path,
|
||||
Some(kind),
|
||||
|
@ -682,7 +682,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
trace: bool,
|
||||
force: bool,
|
||||
ignore_import: Option<Import<'ra>>,
|
||||
) -> Result<(Option<Lrc<SyntaxExtension>>, Res), Determinacy> {
|
||||
) -> Result<(Option<Arc<SyntaxExtension>>, Res), Determinacy> {
|
||||
self.resolve_macro_or_delegation_path(
|
||||
path,
|
||||
kind,
|
||||
|
@ -705,7 +705,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
deleg_impl: Option<LocalDefId>,
|
||||
invoc_in_mod_inert_attr: Option<(LocalDefId, NodeId)>,
|
||||
ignore_import: Option<Import<'ra>>,
|
||||
) -> Result<(Option<Lrc<SyntaxExtension>>, Res), Determinacy> {
|
||||
) -> Result<(Option<Arc<SyntaxExtension>>, Res), Determinacy> {
|
||||
let path_span = ast_path.span;
|
||||
let mut path = Segment::from_path(ast_path);
|
||||
|
||||
|
@ -788,11 +788,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
Some(impl_def_id) => match res {
|
||||
def::Res::Def(DefKind::Trait, def_id) => {
|
||||
let edition = self.tcx.sess.edition();
|
||||
Some(Lrc::new(SyntaxExtension::glob_delegation(def_id, impl_def_id, edition)))
|
||||
Some(Arc::new(SyntaxExtension::glob_delegation(def_id, impl_def_id, edition)))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
None => self.get_macro(res).map(|macro_data| Lrc::clone(¯o_data.ext)),
|
||||
None => self.get_macro(res).map(|macro_data| Arc::clone(¯o_data.ext)),
|
||||
};
|
||||
Ok((ext, res))
|
||||
}
|
||||
|
@ -1130,7 +1130,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
MacroData { ext: Lrc::new(ext), rule_spans, macro_rules: macro_def.macro_rules }
|
||||
MacroData { ext: Arc::new(ext), rule_spans, macro_rules: macro_def.macro_rules }
|
||||
}
|
||||
|
||||
fn path_accessible(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue