Skip to content

Commit 7197a27

Browse files
committed
Use triomphe Arc
1 parent a7168a8 commit 7197a27

Some content is hidden

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

94 files changed

+337
-263
lines changed

Cargo.lock

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ smol_str = "0.2.0"
8181
# the following crates are pinned to prevent us from pulling in syn 2 until all our dependencies have moved
8282
serde = { version = "=1.0.156", features = ["derive"] }
8383
serde_json = "1.0.94"
84+
triomphe = { version = "0.1.8", default-features = false, features = ["std"] }

crates/base-db/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ doctest = false
1515
salsa = "0.17.0-pre.2"
1616
rustc-hash = "1.1.0"
1717

18+
triomphe.workspace = true
19+
1820
la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
1921

2022
# local deps

crates/base-db/src/change.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Defines a unit of change that can applied to the database to get the next
22
//! state. Changes are transactional.
33
4-
use std::{fmt, sync::Arc};
4+
use std::fmt;
55

66
use salsa::Durability;
7+
use triomphe::Arc;
78
use vfs::FileId;
89

910
use crate::{CrateGraph, ProcMacros, SourceDatabaseExt, SourceRoot, SourceRootId};

crates/base-db/src/fixture.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//! A set of high-level utility fixture methods to use in tests.
2-
use std::{mem, str::FromStr, sync::Arc};
2+
use std::{mem, str::FromStr, sync};
33

44
use cfg::CfgOptions;
55
use rustc_hash::FxHashMap;
66
use test_utils::{
77
extract_range_or_offset, Fixture, FixtureWithProjectMeta, RangeOrOffset, CURSOR_MARKER,
88
ESCAPED_CURSOR_MARKER,
99
};
10+
use triomphe::Arc;
1011
use tt::token_id::{Leaf, Subtree, TokenTree};
1112
use vfs::{file_set::FileSet, VfsPath};
1213

@@ -334,7 +335,7 @@ pub fn identity(_attr: TokenStream, item: TokenStream) -> TokenStream {
334335
ProcMacro {
335336
name: "identity".into(),
336337
kind: crate::ProcMacroKind::Attr,
337-
expander: Arc::new(IdentityProcMacroExpander),
338+
expander: sync::Arc::new(IdentityProcMacroExpander),
338339
},
339340
),
340341
(
@@ -348,7 +349,7 @@ pub fn derive_identity(item: TokenStream) -> TokenStream {
348349
ProcMacro {
349350
name: "DeriveIdentity".into(),
350351
kind: crate::ProcMacroKind::CustomDerive,
351-
expander: Arc::new(IdentityProcMacroExpander),
352+
expander: sync::Arc::new(IdentityProcMacroExpander),
352353
},
353354
),
354355
(
@@ -362,7 +363,7 @@ pub fn input_replace(attr: TokenStream, _item: TokenStream) -> TokenStream {
362363
ProcMacro {
363364
name: "input_replace".into(),
364365
kind: crate::ProcMacroKind::Attr,
365-
expander: Arc::new(AttributeInputReplaceProcMacroExpander),
366+
expander: sync::Arc::new(AttributeInputReplaceProcMacroExpander),
366367
},
367368
),
368369
(
@@ -376,7 +377,7 @@ pub fn mirror(input: TokenStream) -> TokenStream {
376377
ProcMacro {
377378
name: "mirror".into(),
378379
kind: crate::ProcMacroKind::FuncLike,
379-
expander: Arc::new(MirrorProcMacroExpander),
380+
expander: sync::Arc::new(MirrorProcMacroExpander),
380381
},
381382
),
382383
(
@@ -390,7 +391,7 @@ pub fn shorten(input: TokenStream) -> TokenStream {
390391
ProcMacro {
391392
name: "shorten".into(),
392393
kind: crate::ProcMacroKind::FuncLike,
393-
expander: Arc::new(ShortenProcMacroExpander),
394+
expander: sync::Arc::new(ShortenProcMacroExpander),
394395
},
395396
),
396397
]

crates/base-db/src/input.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
77
//! actual IO is done and lowered to input.
88
9-
use std::{fmt, mem, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
9+
use std::{fmt, mem, ops, panic::RefUnwindSafe, str::FromStr, sync};
1010

1111
use cfg::CfgOptions;
1212
use la_arena::{Arena, Idx};
1313
use rustc_hash::{FxHashMap, FxHashSet};
1414
use syntax::SmolStr;
15+
use triomphe::Arc;
1516
use tt::token_id::Subtree;
1617
use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
1718

@@ -263,7 +264,7 @@ pub type TargetLayoutLoadResult = Result<Arc<str>, Arc<str>>;
263264
pub struct ProcMacro {
264265
pub name: SmolStr,
265266
pub kind: ProcMacroKind,
266-
pub expander: Arc<dyn ProcMacroExpander>,
267+
pub expander: sync::Arc<dyn ProcMacroExpander>,
267268
}
268269

269270
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]

crates/base-db/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ mod input;
66
mod change;
77
pub mod fixture;
88

9-
use std::{panic, sync::Arc};
9+
use std::panic;
1010

1111
use rustc_hash::FxHashSet;
1212
use syntax::{ast, Parse, SourceFile, TextRange, TextSize};
13+
use triomphe::Arc;
1314

1415
pub use crate::{
1516
change::Change,

crates/hir-def/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ once_cell = "1.17.0"
2929
rustc-hash = "1.1.0"
3030
smallvec.workspace = true
3131
tracing = "0.1.35"
32+
triomphe.workspace = true
3233

3334
rustc_abi = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_abi", default-features = false }
3435
rustc_index = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }

crates/hir-def/src/attr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub mod builtin;
55
#[cfg(test)]
66
mod tests;
77

8-
use std::{hash::Hash, ops, sync::Arc};
8+
use std::{hash::Hash, ops};
99

1010
use base_db::CrateId;
1111
use cfg::{CfgExpr, CfgOptions};
@@ -21,6 +21,7 @@ use syntax::{
2121
ast::{self, HasAttrs, IsString},
2222
AstPtr, AstToken, SmolStr, TextRange, TextSize,
2323
};
24+
use triomphe::Arc;
2425

2526
use crate::{
2627
db::DefDatabase,

crates/hir-def/src/body.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod tests;
66
pub mod scope;
77
mod pretty;
88

9-
use std::{ops::Index, sync::Arc};
9+
use std::ops::Index;
1010

1111
use base_db::CrateId;
1212
use cfg::{CfgExpr, CfgOptions};
@@ -16,6 +16,7 @@ use la_arena::{Arena, ArenaMap};
1616
use profile::Count;
1717
use rustc_hash::FxHashMap;
1818
use syntax::{ast, AstPtr, SyntaxNodePtr};
19+
use triomphe::Arc;
1920

2021
use crate::{
2122
db::DefDatabase,

crates/hir-def/src/body/lower.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr`
22
//! representation.
33
4-
use std::{mem, sync::Arc};
4+
use std::mem;
55

66
use base_db::CrateId;
77
use either::Either;
@@ -22,6 +22,7 @@ use syntax::{
2222
},
2323
AstNode, AstPtr, SyntaxNodePtr,
2424
};
25+
use triomphe::Arc;
2526

2627
use crate::{
2728
body::{Body, BodyDiagnostic, BodySourceMap, ExprPtr, LabelPtr, PatPtr},

crates/hir-def/src/body/scope.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//! Name resolution for expressions.
2-
use std::sync::Arc;
3-
42
use hir_expand::name::Name;
53
use la_arena::{Arena, Idx, IdxRange, RawIdx};
64
use rustc_hash::FxHashMap;
5+
use triomphe::Arc;
76

87
use crate::{
98
body::Body,

crates/hir-def/src/data.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
33
pub mod adt;
44

5-
use std::sync::Arc;
6-
75
use hir_expand::{
86
name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefKind,
97
};
108
use intern::Interned;
119
use smallvec::SmallVec;
1210
use syntax::{ast, Parse};
11+
use triomphe::Arc;
1312

1413
use crate::{
1514
attr::Attrs,

crates/hir-def/src/data/adt.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Defines hir-level representation of structs, enums and unions
22
3-
use std::sync::Arc;
4-
53
use base_db::CrateId;
64
use bitflags::bitflags;
75
use cfg::CfgOptions;
@@ -15,6 +13,7 @@ use intern::Interned;
1513
use la_arena::{Arena, ArenaMap};
1614
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
1715
use syntax::ast::{self, HasName, HasVisibility};
16+
use triomphe::Arc;
1817

1918
use crate::{
2019
builtin_type::{BuiltinInt, BuiltinUint},

crates/hir-def/src/db.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
//! Defines database & queries for name resolution.
2-
use std::sync::Arc;
3-
42
use base_db::{salsa, CrateId, SourceDatabase, Upcast};
53
use either::Either;
64
use hir_expand::{db::ExpandDatabase, HirFileId};
75
use intern::Interned;
86
use la_arena::ArenaMap;
97
use syntax::{ast, AstPtr};
8+
use triomphe::Arc;
109

1110
use crate::{
1211
attr::{Attrs, AttrsWithOwner},

crates/hir-def/src/generics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! generic parameters. See also the `Generics` type and the `generics_of` query
44
//! in rustc.
55
6-
use std::sync::Arc;
7-
86
use base_db::FileId;
97
use either::Either;
108
use hir_expand::{
@@ -16,6 +14,7 @@ use la_arena::{Arena, ArenaMap, Idx};
1614
use once_cell::unsync::Lazy;
1715
use stdx::impl_from;
1816
use syntax::ast::{self, HasGenericParams, HasName, HasTypeBounds};
17+
use triomphe::Arc;
1918

2019
use crate::{
2120
child_by_source::ChildBySource,

crates/hir-def/src/import_map.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//! A map of all publicly exported items in a crate.
22
3-
use std::{fmt, hash::BuildHasherDefault, sync::Arc};
3+
use std::{fmt, hash::BuildHasherDefault};
44

55
use base_db::CrateId;
66
use fst::{self, Streamer};
77
use hir_expand::name::Name;
88
use indexmap::{map::Entry, IndexMap};
99
use itertools::Itertools;
1010
use rustc_hash::{FxHashSet, FxHasher};
11+
use triomphe::Arc;
1112

1213
use crate::{
1314
db::DefDatabase, item_scope::ItemInNs, visibility::Visibility, AssocItemId, ModuleDefId,

0 commit comments

Comments
 (0)