Use triomphe Arc

This commit is contained in:
Laurențiu Nicola 2023-05-02 17:12:22 +03:00
parent a7168a8c6f
commit 7197a27028
94 changed files with 331 additions and 257 deletions

View file

@ -1,9 +1,10 @@
//! Defines a unit of change that can applied to the database to get the next
//! state. Changes are transactional.
use std::{fmt, sync::Arc};
use std::fmt;
use salsa::Durability;
use triomphe::Arc;
use vfs::FileId;
use crate::{CrateGraph, ProcMacros, SourceDatabaseExt, SourceRoot, SourceRootId};

View file

@ -1,5 +1,5 @@
//! A set of high-level utility fixture methods to use in tests.
use std::{mem, str::FromStr, sync::Arc};
use std::{mem, str::FromStr, sync};
use cfg::CfgOptions;
use rustc_hash::FxHashMap;
@ -7,6 +7,7 @@ use test_utils::{
extract_range_or_offset, Fixture, FixtureWithProjectMeta, RangeOrOffset, CURSOR_MARKER,
ESCAPED_CURSOR_MARKER,
};
use triomphe::Arc;
use tt::token_id::{Leaf, Subtree, TokenTree};
use vfs::{file_set::FileSet, VfsPath};
@ -334,7 +335,7 @@ pub fn identity(_attr: TokenStream, item: TokenStream) -> TokenStream {
ProcMacro {
name: "identity".into(),
kind: crate::ProcMacroKind::Attr,
expander: Arc::new(IdentityProcMacroExpander),
expander: sync::Arc::new(IdentityProcMacroExpander),
},
),
(
@ -348,7 +349,7 @@ pub fn derive_identity(item: TokenStream) -> TokenStream {
ProcMacro {
name: "DeriveIdentity".into(),
kind: crate::ProcMacroKind::CustomDerive,
expander: Arc::new(IdentityProcMacroExpander),
expander: sync::Arc::new(IdentityProcMacroExpander),
},
),
(
@ -362,7 +363,7 @@ pub fn input_replace(attr: TokenStream, _item: TokenStream) -> TokenStream {
ProcMacro {
name: "input_replace".into(),
kind: crate::ProcMacroKind::Attr,
expander: Arc::new(AttributeInputReplaceProcMacroExpander),
expander: sync::Arc::new(AttributeInputReplaceProcMacroExpander),
},
),
(
@ -376,7 +377,7 @@ pub fn mirror(input: TokenStream) -> TokenStream {
ProcMacro {
name: "mirror".into(),
kind: crate::ProcMacroKind::FuncLike,
expander: Arc::new(MirrorProcMacroExpander),
expander: sync::Arc::new(MirrorProcMacroExpander),
},
),
(
@ -390,7 +391,7 @@ pub fn shorten(input: TokenStream) -> TokenStream {
ProcMacro {
name: "shorten".into(),
kind: crate::ProcMacroKind::FuncLike,
expander: Arc::new(ShortenProcMacroExpander),
expander: sync::Arc::new(ShortenProcMacroExpander),
},
),
]

View file

@ -6,12 +6,13 @@
//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
//! actual IO is done and lowered to input.
use std::{fmt, mem, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
use std::{fmt, mem, ops, panic::RefUnwindSafe, str::FromStr, sync};
use cfg::CfgOptions;
use la_arena::{Arena, Idx};
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::SmolStr;
use triomphe::Arc;
use tt::token_id::Subtree;
use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
@ -263,7 +264,7 @@ pub type TargetLayoutLoadResult = Result<Arc<str>, Arc<str>>;
pub struct ProcMacro {
pub name: SmolStr,
pub kind: ProcMacroKind,
pub expander: Arc<dyn ProcMacroExpander>,
pub expander: sync::Arc<dyn ProcMacroExpander>,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]

View file

@ -6,10 +6,11 @@ mod input;
mod change;
pub mod fixture;
use std::{panic, sync::Arc};
use std::panic;
use rustc_hash::FxHashSet;
use syntax::{ast, Parse, SourceFile, TextRange, TextSize};
use triomphe::Arc;
pub use crate::{
change::Change,