Skip to content

Commit 38013fb

Browse files
committed
Lrc -> Arc
1 parent 8977616 commit 38013fb

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/attribute.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
//
33
// SPDX-License-Identifier: MIT OR Apache-2.0
44

5+
use std::sync::Arc;
6+
57
use rustc_ast::tokenstream::{self, TokenTree};
68
use rustc_ast::{token, DelimArgs};
7-
use rustc_data_structures::sync::Lrc;
89
use rustc_errors::{Diag, ErrorGuaranteed};
910
use rustc_hir::{AttrArgs, AttrItem, AttrKind, Attribute, HirId};
1011
use rustc_middle::ty::TyCtxt;
@@ -460,14 +461,14 @@ memoize!(
460461
pub fn klint_attributes<'tcx>(
461462
cx: &AnalysisCtxt<'tcx>,
462463
hir_id: HirId,
463-
) -> Lrc<Vec<KlintAttribute>> {
464+
) -> Arc<Vec<KlintAttribute>> {
464465
let mut v = Vec::new();
465466
for attr in cx.hir().attrs(hir_id) {
466467
let Some(attr) = crate::attribute::parse_klint_attribute(cx.tcx, hir_id, attr) else {
467468
continue;
468469
};
469470
v.push(attr);
470471
}
471-
Lrc::new(v)
472+
Arc::new(v)
472473
}
473474
);

src/ctxt.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::sync::Arc;
88

99
use rusqlite::{Connection, OptionalExtension};
1010
use rustc_data_structures::fx::FxHashMap;
11-
use rustc_data_structures::sync::Lrc;
1211
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
1312
use rustc_middle::ty::TyCtxt;
1413
use rustc_serialize::{Decodable, Encodable};
@@ -52,10 +51,10 @@ pub(crate) trait PersistentQuery: QueryValueDecodable {
5251
pub struct AnalysisCtxt<'tcx> {
5352
pub tcx: TyCtxt<'tcx>,
5453
pub local_conn: Connection,
55-
pub sql_conn: RefCell<FxHashMap<CrateNum, Option<Lrc<Connection>>>>,
54+
pub sql_conn: RefCell<FxHashMap<CrateNum, Option<Arc<Connection>>>>,
5655

5756
pub call_stack: RefCell<Vec<UseSite<'tcx>>>,
58-
pub query_cache: RefCell<FxHashMap<TypeId, Lrc<dyn Any>>>,
57+
pub query_cache: RefCell<FxHashMap<TypeId, Arc<dyn Any>>>,
5958
}
6059

6160
impl<'tcx> std::ops::Deref for AnalysisCtxt<'tcx> {
@@ -128,13 +127,13 @@ impl ArcDowncast for Arc<dyn Any> {
128127
impl<'tcx> AnalysisCtxt<'tcx> {
129128
pub(crate) fn query_cache<Q: Query>(
130129
&self,
131-
) -> Lrc<RefCell<FxHashMap<Q::Key<'tcx>, Q::Value<'tcx>>>> {
130+
) -> Arc<RefCell<FxHashMap<Q::Key<'tcx>, Q::Value<'tcx>>>> {
132131
let key = TypeId::of::<Q>();
133132
let mut guard = self.query_cache.borrow_mut();
134133
let cache = guard
135134
.entry(key)
136135
.or_insert_with(|| {
137-
let cache = Lrc::new(RefCell::new(
136+
let cache = Arc::new(RefCell::new(
138137
FxHashMap::<Q::Key<'static>, Q::Value<'static>>::default(),
139138
));
140139
cache
@@ -147,7 +146,7 @@ impl<'tcx> AnalysisCtxt<'tcx> {
147146
unsafe { std::mem::transmute(cache) }
148147
}
149148

150-
pub(crate) fn sql_connection(&self, cnum: CrateNum) -> Option<Lrc<Connection>> {
149+
pub(crate) fn sql_connection(&self, cnum: CrateNum) -> Option<Arc<Connection>> {
151150
if let Some(v) = self.sql_conn.borrow().get(&cnum) {
152151
return v.clone();
153152
}
@@ -188,7 +187,7 @@ impl<'tcx> AnalysisCtxt<'tcx> {
188187
);
189188
}
190189

191-
result = Some(Lrc::new(conn));
190+
result = Some(Arc::new(conn));
192191
break;
193192
}
194193
}

src/serde.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
//
33
// SPDX-License-Identifier: MIT OR Apache-2.0
44

5+
use std::sync::Arc;
6+
57
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
6-
use rustc_data_structures::sync::Lrc;
78
use rustc_middle::mir::interpret::{self, AllocDecodingState, AllocId};
89
use rustc_middle::ty::{self, Ty, TyCtxt, TyDecoder, TyEncoder};
910
use rustc_serialize::opaque::{MemDecoder, MAGIC_END_BYTES};
@@ -113,7 +114,7 @@ pub struct EncodeContext<'tcx> {
113114
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
114115
predicate_shorthands: FxHashMap<ty::PredicateKind<'tcx>, usize>,
115116
interpret_allocs: FxIndexSet<AllocId>,
116-
relative_file: Lrc<SourceFile>,
117+
relative_file: Arc<SourceFile>,
117118
}
118119

119120
impl<'tcx> EncodeContext<'tcx> {
@@ -239,7 +240,7 @@ impl<'tcx> SpanEncoder for EncodeContext<'tcx> {
239240
return TAG_PARTIAL_SPAN.encode(self);
240241
}
241242

242-
if Lrc::ptr_eq(&pos.sf, &self.relative_file) {
243+
if Arc::ptr_eq(&pos.sf, &self.relative_file) {
243244
TAG_RELATIVE_SPAN.encode(self);
244245
(span.lo - self.relative_file.start_pos).encode(self);
245246
(span.hi - self.relative_file.start_pos).encode(self);
@@ -274,9 +275,9 @@ pub struct DecodeContext<'a, 'tcx> {
274275
decoder: MemDecoder<'a>,
275276
tcx: TyCtxt<'tcx>,
276277
type_shorthands: FxHashMap<usize, Ty<'tcx>>,
277-
alloc_decoding_state: Lrc<AllocDecodingState>,
278+
alloc_decoding_state: Arc<AllocDecodingState>,
278279
replacement_span: Span,
279-
relative_file: Lrc<SourceFile>,
280+
relative_file: Arc<SourceFile>,
280281
}
281282

282283
impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
@@ -289,7 +290,7 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
289290
let mut decoder = MemDecoder::new(bytes, vec_position).unwrap();
290291
let interpret_alloc_index = Vec::<u64>::decode(&mut decoder);
291292
let alloc_decoding_state =
292-
Lrc::new(interpret::AllocDecodingState::new(interpret_alloc_index));
293+
Arc::new(interpret::AllocDecodingState::new(interpret_alloc_index));
293294

294295
Self {
295296
decoder: MemDecoder::new(bytes, 0).unwrap(),

0 commit comments

Comments
 (0)