chore: rename salsa to ra_salsa

This commit is contained in:
David Barsky 2024-10-04 15:48:11 -04:00
parent 7b2548bd8d
commit ccee36e8dd
104 changed files with 540 additions and 538 deletions

View file

@ -20,7 +20,7 @@ rustc-hash.opt-level = 3
smol_str.opt-level = 3 smol_str.opt-level = 3
text-size.opt-level = 3 text-size.opt-level = 3
serde.opt-level = 3 serde.opt-level = 3
salsa.opt-level = 3 ra-salsa.opt-level = 3
# This speeds up `cargo xtask dist`. # This speeds up `cargo xtask dist`.
miniz_oxide.opt-level = 3 miniz_oxide.opt-level = 3
@ -74,7 +74,7 @@ proc-macro-srv = { path = "./crates/proc-macro-srv", version = "0.0.0" }
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" } proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
profile = { path = "./crates/profile", version = "0.0.0" } profile = { path = "./crates/profile", version = "0.0.0" }
project-model = { path = "./crates/project-model", version = "0.0.0" } project-model = { path = "./crates/project-model", version = "0.0.0" }
salsa = { path = "./crates/salsa", version = "0.0.0" } ra-salsa = { path = "./crates/ra-salsa", package = "salsa", version = "0.0.0" }
span = { path = "./crates/span", version = "0.0.0" } span = { path = "./crates/span", version = "0.0.0" }
stdx = { path = "./crates/stdx", version = "0.0.0" } stdx = { path = "./crates/stdx", version = "0.0.0" }
syntax = { path = "./crates/syntax", version = "0.0.0" } syntax = { path = "./crates/syntax", version = "0.0.0" }

View file

@ -16,7 +16,7 @@ doctest = false
lz4_flex = { version = "0.11", default-features = false } lz4_flex = { version = "0.11", default-features = false }
la-arena.workspace = true la-arena.workspace = true
salsa.workspace = true ra-salsa.workspace = true
rustc-hash.workspace = true rustc-hash.workspace = true
triomphe.workspace = true triomphe.workspace = true
semver.workspace = true semver.workspace = true

View file

@ -3,8 +3,8 @@
use std::fmt; use std::fmt;
use ra_salsa::Durability;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use salsa::Durability;
use triomphe::Arc; use triomphe::Arc;
use vfs::FileId; use vfs::FileId;

View file

@ -5,8 +5,8 @@ mod input;
use std::panic; use std::panic;
use ra_salsa::Durability;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use salsa::Durability;
use span::EditionedFileId; use span::EditionedFileId;
use syntax::{ast, Parse, SourceFile, SyntaxError}; use syntax::{ast, Parse, SourceFile, SyntaxError};
use triomphe::Arc; use triomphe::Arc;
@ -20,7 +20,7 @@ pub use crate::{
TargetLayoutLoadResult, TargetLayoutLoadResult,
}, },
}; };
pub use salsa::{self, Cancelled}; pub use ra_salsa::{self, Cancelled};
pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, VfsPath}; pub use vfs::{file_set::FileSet, AnchoredPath, AnchoredPathBuf, VfsPath};
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq}; pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
@ -28,11 +28,11 @@ pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
#[macro_export] #[macro_export]
macro_rules! impl_intern_key { macro_rules! impl_intern_key {
($name:ident) => { ($name:ident) => {
impl $crate::salsa::InternKey for $name { impl $crate::ra_salsa::InternKey for $name {
fn from_intern_id(v: $crate::salsa::InternId) -> Self { fn from_intern_id(v: $crate::ra_salsa::InternId) -> Self {
$name(v) $name(v)
} }
fn as_intern_id(&self) -> $crate::salsa::InternId { fn as_intern_id(&self) -> $crate::ra_salsa::InternId {
self.0 self.0
} }
} }
@ -55,30 +55,30 @@ pub trait FileLoader {
/// Database which stores all significant input facts: source code and project /// Database which stores all significant input facts: source code and project
/// model. Everything else in rust-analyzer is derived from these queries. /// model. Everything else in rust-analyzer is derived from these queries.
#[salsa::query_group(SourceDatabaseStorage)] #[ra_salsa::query_group(SourceDatabaseStorage)]
pub trait SourceDatabase: FileLoader + std::fmt::Debug { pub trait SourceDatabase: FileLoader + std::fmt::Debug {
#[salsa::input] #[ra_salsa::input]
fn compressed_file_text(&self, file_id: FileId) -> Arc<[u8]>; fn compressed_file_text(&self, file_id: FileId) -> Arc<[u8]>;
/// Text of the file. /// Text of the file.
#[salsa::lru] #[ra_salsa::lru]
fn file_text(&self, file_id: FileId) -> Arc<str>; fn file_text(&self, file_id: FileId) -> Arc<str>;
/// Parses the file into the syntax tree. /// Parses the file into the syntax tree.
#[salsa::lru] #[ra_salsa::lru]
fn parse(&self, file_id: EditionedFileId) -> Parse<ast::SourceFile>; fn parse(&self, file_id: EditionedFileId) -> Parse<ast::SourceFile>;
/// Returns the set of errors obtained from parsing the file including validation errors. /// Returns the set of errors obtained from parsing the file including validation errors.
fn parse_errors(&self, file_id: EditionedFileId) -> Option<Arc<[SyntaxError]>>; fn parse_errors(&self, file_id: EditionedFileId) -> Option<Arc<[SyntaxError]>>;
/// The crate graph. /// The crate graph.
#[salsa::input] #[ra_salsa::input]
fn crate_graph(&self) -> Arc<CrateGraph>; fn crate_graph(&self) -> Arc<CrateGraph>;
#[salsa::input] #[ra_salsa::input]
fn crate_workspace_data(&self) -> Arc<FxHashMap<CrateId, Arc<CrateWorkspaceData>>>; fn crate_workspace_data(&self) -> Arc<FxHashMap<CrateId, Arc<CrateWorkspaceData>>>;
#[salsa::transparent] #[ra_salsa::transparent]
fn toolchain_channel(&self, krate: CrateId) -> Option<ReleaseChannel>; fn toolchain_channel(&self, krate: CrateId) -> Option<ReleaseChannel>;
} }
@ -126,14 +126,14 @@ fn file_text(db: &dyn SourceDatabase, file_id: FileId) -> Arc<str> {
/// We don't want to give HIR knowledge of source roots, hence we extract these /// We don't want to give HIR knowledge of source roots, hence we extract these
/// methods into a separate DB. /// methods into a separate DB.
#[salsa::query_group(SourceRootDatabaseStorage)] #[ra_salsa::query_group(SourceRootDatabaseStorage)]
pub trait SourceRootDatabase: SourceDatabase { pub trait SourceRootDatabase: SourceDatabase {
/// Path to a file, relative to the root of its source root. /// Path to a file, relative to the root of its source root.
/// Source root of the file. /// Source root of the file.
#[salsa::input] #[ra_salsa::input]
fn file_source_root(&self, file_id: FileId) -> SourceRootId; fn file_source_root(&self, file_id: FileId) -> SourceRootId;
/// Contents of the source root. /// Contents of the source root.
#[salsa::input] #[ra_salsa::input]
fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>; fn source_root(&self, id: SourceRootId) -> Arc<SourceRoot>;
/// Crates whose root fool is in `id`. /// Crates whose root fool is in `id`.

View file

@ -1,5 +1,5 @@
//! Defines database & queries for name resolution. //! Defines database & queries for name resolution.
use base_db::{salsa, CrateId, SourceDatabase, Upcast}; use base_db::{ra_salsa, CrateId, SourceDatabase, Upcast};
use either::Either; use either::Either;
use hir_expand::{db::ExpandDatabase, HirFileId, MacroDefId}; use hir_expand::{db::ExpandDatabase, HirFileId, MacroDefId};
use intern::{sym, Interned}; use intern::{sym, Interned};
@ -31,71 +31,71 @@ use crate::{
UseId, UseLoc, VariantId, UseId, UseLoc, VariantId,
}; };
#[salsa::query_group(InternDatabaseStorage)] #[ra_salsa::query_group(InternDatabaseStorage)]
pub trait InternDatabase: SourceDatabase { pub trait InternDatabase: SourceDatabase {
// region: items // region: items
#[salsa::interned] #[ra_salsa::interned]
fn intern_use(&self, loc: UseLoc) -> UseId; fn intern_use(&self, loc: UseLoc) -> UseId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_extern_crate(&self, loc: ExternCrateLoc) -> ExternCrateId; fn intern_extern_crate(&self, loc: ExternCrateLoc) -> ExternCrateId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_function(&self, loc: FunctionLoc) -> FunctionId; fn intern_function(&self, loc: FunctionLoc) -> FunctionId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_struct(&self, loc: StructLoc) -> StructId; fn intern_struct(&self, loc: StructLoc) -> StructId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_union(&self, loc: UnionLoc) -> UnionId; fn intern_union(&self, loc: UnionLoc) -> UnionId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_enum(&self, loc: EnumLoc) -> EnumId; fn intern_enum(&self, loc: EnumLoc) -> EnumId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_enum_variant(&self, loc: EnumVariantLoc) -> EnumVariantId; fn intern_enum_variant(&self, loc: EnumVariantLoc) -> EnumVariantId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_const(&self, loc: ConstLoc) -> ConstId; fn intern_const(&self, loc: ConstLoc) -> ConstId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_static(&self, loc: StaticLoc) -> StaticId; fn intern_static(&self, loc: StaticLoc) -> StaticId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_trait(&self, loc: TraitLoc) -> TraitId; fn intern_trait(&self, loc: TraitLoc) -> TraitId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_trait_alias(&self, loc: TraitAliasLoc) -> TraitAliasId; fn intern_trait_alias(&self, loc: TraitAliasLoc) -> TraitAliasId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_type_alias(&self, loc: TypeAliasLoc) -> TypeAliasId; fn intern_type_alias(&self, loc: TypeAliasLoc) -> TypeAliasId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_impl(&self, loc: ImplLoc) -> ImplId; fn intern_impl(&self, loc: ImplLoc) -> ImplId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_extern_block(&self, loc: ExternBlockLoc) -> ExternBlockId; fn intern_extern_block(&self, loc: ExternBlockLoc) -> ExternBlockId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_macro2(&self, loc: Macro2Loc) -> Macro2Id; fn intern_macro2(&self, loc: Macro2Loc) -> Macro2Id;
#[salsa::interned] #[ra_salsa::interned]
fn intern_proc_macro(&self, loc: ProcMacroLoc) -> ProcMacroId; fn intern_proc_macro(&self, loc: ProcMacroLoc) -> ProcMacroId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_macro_rules(&self, loc: MacroRulesLoc) -> MacroRulesId; fn intern_macro_rules(&self, loc: MacroRulesLoc) -> MacroRulesId;
// endregion: items // endregion: items
#[salsa::interned] #[ra_salsa::interned]
fn intern_block(&self, loc: BlockLoc) -> BlockId; fn intern_block(&self, loc: BlockLoc) -> BlockId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_anonymous_const(&self, id: ConstBlockLoc) -> ConstBlockId; fn intern_anonymous_const(&self, id: ConstBlockLoc) -> ConstBlockId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_in_type_const(&self, id: InTypeConstLoc) -> InTypeConstId; fn intern_in_type_const(&self, id: InTypeConstLoc) -> InTypeConstId;
} }
#[salsa::query_group(DefDatabaseStorage)] #[ra_salsa::query_group(DefDatabaseStorage)]
pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDatabase> { pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDatabase> {
/// Whether to expand procedural macros during name resolution. /// Whether to expand procedural macros during name resolution.
#[salsa::input] #[ra_salsa::input]
fn expand_proc_attr_macros(&self) -> bool; fn expand_proc_attr_macros(&self) -> bool;
/// Computes an [`ItemTree`] for the given file or macro expansion. /// Computes an [`ItemTree`] for the given file or macro expansion.
#[salsa::invoke(ItemTree::file_item_tree_query)] #[ra_salsa::invoke(ItemTree::file_item_tree_query)]
fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>; fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>;
#[salsa::invoke(ItemTree::block_item_tree_query)] #[ra_salsa::invoke(ItemTree::block_item_tree_query)]
fn block_item_tree(&self, block_id: BlockId) -> Arc<ItemTree>; fn block_item_tree(&self, block_id: BlockId) -> Arc<ItemTree>;
#[salsa::invoke(DefMap::crate_def_map_query)] #[ra_salsa::invoke(DefMap::crate_def_map_query)]
fn crate_def_map(&self, krate: CrateId) -> Arc<DefMap>; fn crate_def_map(&self, krate: CrateId) -> Arc<DefMap>;
/// Computes the block-level `DefMap`. /// Computes the block-level `DefMap`.
#[salsa::invoke(DefMap::block_def_map_query)] #[ra_salsa::invoke(DefMap::block_def_map_query)]
fn block_def_map(&self, block: BlockId) -> Arc<DefMap>; fn block_def_map(&self, block: BlockId) -> Arc<DefMap>;
/// Turns a MacroId into a MacroDefId, describing the macro's definition post name resolution. /// Turns a MacroId into a MacroDefId, describing the macro's definition post name resolution.
@ -103,139 +103,139 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
// region:data // region:data
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(StructData::struct_data_query)] #[ra_salsa::invoke(StructData::struct_data_query)]
fn struct_data(&self, id: StructId) -> Arc<StructData>; fn struct_data(&self, id: StructId) -> Arc<StructData>;
#[salsa::invoke(StructData::struct_data_with_diagnostics_query)] #[ra_salsa::invoke(StructData::struct_data_with_diagnostics_query)]
fn struct_data_with_diagnostics(&self, id: StructId) -> (Arc<StructData>, DefDiagnostics); fn struct_data_with_diagnostics(&self, id: StructId) -> (Arc<StructData>, DefDiagnostics);
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(StructData::union_data_query)] #[ra_salsa::invoke(StructData::union_data_query)]
fn union_data(&self, id: UnionId) -> Arc<StructData>; fn union_data(&self, id: UnionId) -> Arc<StructData>;
#[salsa::invoke(StructData::union_data_with_diagnostics_query)] #[ra_salsa::invoke(StructData::union_data_with_diagnostics_query)]
fn union_data_with_diagnostics(&self, id: UnionId) -> (Arc<StructData>, DefDiagnostics); fn union_data_with_diagnostics(&self, id: UnionId) -> (Arc<StructData>, DefDiagnostics);
#[salsa::invoke(EnumData::enum_data_query)] #[ra_salsa::invoke(EnumData::enum_data_query)]
fn enum_data(&self, e: EnumId) -> Arc<EnumData>; fn enum_data(&self, e: EnumId) -> Arc<EnumData>;
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(EnumVariantData::enum_variant_data_query)] #[ra_salsa::invoke(EnumVariantData::enum_variant_data_query)]
fn enum_variant_data(&self, id: EnumVariantId) -> Arc<EnumVariantData>; fn enum_variant_data(&self, id: EnumVariantId) -> Arc<EnumVariantData>;
#[salsa::invoke(EnumVariantData::enum_variant_data_with_diagnostics_query)] #[ra_salsa::invoke(EnumVariantData::enum_variant_data_with_diagnostics_query)]
fn enum_variant_data_with_diagnostics( fn enum_variant_data_with_diagnostics(
&self, &self,
id: EnumVariantId, id: EnumVariantId,
) -> (Arc<EnumVariantData>, DefDiagnostics); ) -> (Arc<EnumVariantData>, DefDiagnostics);
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(VariantData::variant_data)] #[ra_salsa::invoke(VariantData::variant_data)]
fn variant_data(&self, id: VariantId) -> Arc<VariantData>; fn variant_data(&self, id: VariantId) -> Arc<VariantData>;
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(ImplData::impl_data_query)] #[ra_salsa::invoke(ImplData::impl_data_query)]
fn impl_data(&self, e: ImplId) -> Arc<ImplData>; fn impl_data(&self, e: ImplId) -> Arc<ImplData>;
#[salsa::invoke(ImplData::impl_data_with_diagnostics_query)] #[ra_salsa::invoke(ImplData::impl_data_with_diagnostics_query)]
fn impl_data_with_diagnostics(&self, e: ImplId) -> (Arc<ImplData>, DefDiagnostics); fn impl_data_with_diagnostics(&self, e: ImplId) -> (Arc<ImplData>, DefDiagnostics);
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(TraitData::trait_data_query)] #[ra_salsa::invoke(TraitData::trait_data_query)]
fn trait_data(&self, e: TraitId) -> Arc<TraitData>; fn trait_data(&self, e: TraitId) -> Arc<TraitData>;
#[salsa::invoke(TraitData::trait_data_with_diagnostics_query)] #[ra_salsa::invoke(TraitData::trait_data_with_diagnostics_query)]
fn trait_data_with_diagnostics(&self, tr: TraitId) -> (Arc<TraitData>, DefDiagnostics); fn trait_data_with_diagnostics(&self, tr: TraitId) -> (Arc<TraitData>, DefDiagnostics);
#[salsa::invoke(TraitAliasData::trait_alias_query)] #[ra_salsa::invoke(TraitAliasData::trait_alias_query)]
fn trait_alias_data(&self, e: TraitAliasId) -> Arc<TraitAliasData>; fn trait_alias_data(&self, e: TraitAliasId) -> Arc<TraitAliasData>;
#[salsa::invoke(TypeAliasData::type_alias_data_query)] #[ra_salsa::invoke(TypeAliasData::type_alias_data_query)]
fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>; fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>;
#[salsa::invoke(FunctionData::fn_data_query)] #[ra_salsa::invoke(FunctionData::fn_data_query)]
fn function_data(&self, func: FunctionId) -> Arc<FunctionData>; fn function_data(&self, func: FunctionId) -> Arc<FunctionData>;
#[salsa::invoke(ConstData::const_data_query)] #[ra_salsa::invoke(ConstData::const_data_query)]
fn const_data(&self, konst: ConstId) -> Arc<ConstData>; fn const_data(&self, konst: ConstId) -> Arc<ConstData>;
#[salsa::invoke(StaticData::static_data_query)] #[ra_salsa::invoke(StaticData::static_data_query)]
fn static_data(&self, statik: StaticId) -> Arc<StaticData>; fn static_data(&self, statik: StaticId) -> Arc<StaticData>;
#[salsa::invoke(Macro2Data::macro2_data_query)] #[ra_salsa::invoke(Macro2Data::macro2_data_query)]
fn macro2_data(&self, makro: Macro2Id) -> Arc<Macro2Data>; fn macro2_data(&self, makro: Macro2Id) -> Arc<Macro2Data>;
#[salsa::invoke(MacroRulesData::macro_rules_data_query)] #[ra_salsa::invoke(MacroRulesData::macro_rules_data_query)]
fn macro_rules_data(&self, makro: MacroRulesId) -> Arc<MacroRulesData>; fn macro_rules_data(&self, makro: MacroRulesId) -> Arc<MacroRulesData>;
#[salsa::invoke(ProcMacroData::proc_macro_data_query)] #[ra_salsa::invoke(ProcMacroData::proc_macro_data_query)]
fn proc_macro_data(&self, makro: ProcMacroId) -> Arc<ProcMacroData>; fn proc_macro_data(&self, makro: ProcMacroId) -> Arc<ProcMacroData>;
#[salsa::invoke(ExternCrateDeclData::extern_crate_decl_data_query)] #[ra_salsa::invoke(ExternCrateDeclData::extern_crate_decl_data_query)]
fn extern_crate_decl_data(&self, extern_crate: ExternCrateId) -> Arc<ExternCrateDeclData>; fn extern_crate_decl_data(&self, extern_crate: ExternCrateId) -> Arc<ExternCrateDeclData>;
// endregion:data // endregion:data
#[salsa::invoke(Body::body_with_source_map_query)] #[ra_salsa::invoke(Body::body_with_source_map_query)]
#[salsa::lru] #[ra_salsa::lru]
fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>); fn body_with_source_map(&self, def: DefWithBodyId) -> (Arc<Body>, Arc<BodySourceMap>);
#[salsa::invoke(Body::body_query)] #[ra_salsa::invoke(Body::body_query)]
fn body(&self, def: DefWithBodyId) -> Arc<Body>; fn body(&self, def: DefWithBodyId) -> Arc<Body>;
#[salsa::invoke(ExprScopes::expr_scopes_query)] #[ra_salsa::invoke(ExprScopes::expr_scopes_query)]
fn expr_scopes(&self, def: DefWithBodyId) -> Arc<ExprScopes>; fn expr_scopes(&self, def: DefWithBodyId) -> Arc<ExprScopes>;
#[salsa::invoke(GenericParams::generic_params_query)] #[ra_salsa::invoke(GenericParams::generic_params_query)]
fn generic_params(&self, def: GenericDefId) -> Interned<GenericParams>; fn generic_params(&self, def: GenericDefId) -> Interned<GenericParams>;
// region:attrs // region:attrs
#[salsa::invoke(Attrs::fields_attrs_query)] #[ra_salsa::invoke(Attrs::fields_attrs_query)]
fn fields_attrs(&self, def: VariantId) -> Arc<ArenaMap<LocalFieldId, Attrs>>; fn fields_attrs(&self, def: VariantId) -> Arc<ArenaMap<LocalFieldId, Attrs>>;
// should this really be a query? // should this really be a query?
#[salsa::invoke(crate::attr::fields_attrs_source_map)] #[ra_salsa::invoke(crate::attr::fields_attrs_source_map)]
fn fields_attrs_source_map( fn fields_attrs_source_map(
&self, &self,
def: VariantId, def: VariantId,
) -> Arc<ArenaMap<LocalFieldId, AstPtr<Either<ast::TupleField, ast::RecordField>>>>; ) -> Arc<ArenaMap<LocalFieldId, AstPtr<Either<ast::TupleField, ast::RecordField>>>>;
#[salsa::invoke(AttrsWithOwner::attrs_query)] #[ra_salsa::invoke(AttrsWithOwner::attrs_query)]
fn attrs(&self, def: AttrDefId) -> Attrs; fn attrs(&self, def: AttrDefId) -> Attrs;
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(lang_item::lang_attr)] #[ra_salsa::invoke(lang_item::lang_attr)]
fn lang_attr(&self, def: AttrDefId) -> Option<LangItem>; fn lang_attr(&self, def: AttrDefId) -> Option<LangItem>;
// endregion:attrs // endregion:attrs
#[salsa::invoke(LangItems::lang_item_query)] #[ra_salsa::invoke(LangItems::lang_item_query)]
fn lang_item(&self, start_crate: CrateId, item: LangItem) -> Option<LangItemTarget>; fn lang_item(&self, start_crate: CrateId, item: LangItem) -> Option<LangItemTarget>;
#[salsa::invoke(ImportMap::import_map_query)] #[ra_salsa::invoke(ImportMap::import_map_query)]
fn import_map(&self, krate: CrateId) -> Arc<ImportMap>; fn import_map(&self, krate: CrateId) -> Arc<ImportMap>;
// region:visibilities // region:visibilities
#[salsa::invoke(visibility::field_visibilities_query)] #[ra_salsa::invoke(visibility::field_visibilities_query)]
fn field_visibilities(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Visibility>>; fn field_visibilities(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Visibility>>;
// FIXME: unify function_visibility and const_visibility? // FIXME: unify function_visibility and const_visibility?
#[salsa::invoke(visibility::function_visibility_query)] #[ra_salsa::invoke(visibility::function_visibility_query)]
fn function_visibility(&self, def: FunctionId) -> Visibility; fn function_visibility(&self, def: FunctionId) -> Visibility;
#[salsa::invoke(visibility::const_visibility_query)] #[ra_salsa::invoke(visibility::const_visibility_query)]
fn const_visibility(&self, def: ConstId) -> Visibility; fn const_visibility(&self, def: ConstId) -> Visibility;
// endregion:visibilities // endregion:visibilities
#[salsa::invoke(LangItems::crate_lang_items_query)] #[ra_salsa::invoke(LangItems::crate_lang_items_query)]
fn crate_lang_items(&self, krate: CrateId) -> Option<Arc<LangItems>>; fn crate_lang_items(&self, krate: CrateId) -> Option<Arc<LangItems>>;
#[salsa::invoke(crate::lang_item::notable_traits_in_deps)] #[ra_salsa::invoke(crate::lang_item::notable_traits_in_deps)]
fn notable_traits_in_deps(&self, krate: CrateId) -> Arc<[Arc<[TraitId]>]>; fn notable_traits_in_deps(&self, krate: CrateId) -> Arc<[Arc<[TraitId]>]>;
#[salsa::invoke(crate::lang_item::crate_notable_traits)] #[ra_salsa::invoke(crate::lang_item::crate_notable_traits)]
fn crate_notable_traits(&self, krate: CrateId) -> Option<Arc<[TraitId]>>; fn crate_notable_traits(&self, krate: CrateId) -> Option<Arc<[TraitId]>>;
fn crate_supports_no_std(&self, crate_id: CrateId) -> bool; fn crate_supports_no_std(&self, crate_id: CrateId) -> bool;

View file

@ -71,7 +71,7 @@ use std::{
use base_db::{ use base_db::{
impl_intern_key, impl_intern_key,
salsa::{self, InternValueTrivial}, ra_salsa::{self, InternValueTrivial},
CrateId, CrateId,
}; };
use hir_expand::{ use hir_expand::{
@ -206,85 +206,85 @@ macro_rules! impl_loc {
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FunctionId(salsa::InternId); pub struct FunctionId(ra_salsa::InternId);
type FunctionLoc = AssocItemLoc<Function>; type FunctionLoc = AssocItemLoc<Function>;
impl_intern!(FunctionId, FunctionLoc, intern_function, lookup_intern_function); impl_intern!(FunctionId, FunctionLoc, intern_function, lookup_intern_function);
impl_loc!(FunctionLoc, id: Function, container: ItemContainerId); impl_loc!(FunctionLoc, id: Function, container: ItemContainerId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct StructId(salsa::InternId); pub struct StructId(ra_salsa::InternId);
type StructLoc = ItemLoc<Struct>; type StructLoc = ItemLoc<Struct>;
impl_intern!(StructId, StructLoc, intern_struct, lookup_intern_struct); impl_intern!(StructId, StructLoc, intern_struct, lookup_intern_struct);
impl_loc!(StructLoc, id: Struct, container: ModuleId); impl_loc!(StructLoc, id: Struct, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UnionId(salsa::InternId); pub struct UnionId(ra_salsa::InternId);
pub type UnionLoc = ItemLoc<Union>; pub type UnionLoc = ItemLoc<Union>;
impl_intern!(UnionId, UnionLoc, intern_union, lookup_intern_union); impl_intern!(UnionId, UnionLoc, intern_union, lookup_intern_union);
impl_loc!(UnionLoc, id: Union, container: ModuleId); impl_loc!(UnionLoc, id: Union, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct EnumId(salsa::InternId); pub struct EnumId(ra_salsa::InternId);
pub type EnumLoc = ItemLoc<Enum>; pub type EnumLoc = ItemLoc<Enum>;
impl_intern!(EnumId, EnumLoc, intern_enum, lookup_intern_enum); impl_intern!(EnumId, EnumLoc, intern_enum, lookup_intern_enum);
impl_loc!(EnumLoc, id: Enum, container: ModuleId); impl_loc!(EnumLoc, id: Enum, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ConstId(salsa::InternId); pub struct ConstId(ra_salsa::InternId);
type ConstLoc = AssocItemLoc<Const>; type ConstLoc = AssocItemLoc<Const>;
impl_intern!(ConstId, ConstLoc, intern_const, lookup_intern_const); impl_intern!(ConstId, ConstLoc, intern_const, lookup_intern_const);
impl_loc!(ConstLoc, id: Const, container: ItemContainerId); impl_loc!(ConstLoc, id: Const, container: ItemContainerId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct StaticId(salsa::InternId); pub struct StaticId(ra_salsa::InternId);
pub type StaticLoc = AssocItemLoc<Static>; pub type StaticLoc = AssocItemLoc<Static>;
impl_intern!(StaticId, StaticLoc, intern_static, lookup_intern_static); impl_intern!(StaticId, StaticLoc, intern_static, lookup_intern_static);
impl_loc!(StaticLoc, id: Static, container: ItemContainerId); impl_loc!(StaticLoc, id: Static, container: ItemContainerId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct TraitId(salsa::InternId); pub struct TraitId(ra_salsa::InternId);
pub type TraitLoc = ItemLoc<Trait>; pub type TraitLoc = ItemLoc<Trait>;
impl_intern!(TraitId, TraitLoc, intern_trait, lookup_intern_trait); impl_intern!(TraitId, TraitLoc, intern_trait, lookup_intern_trait);
impl_loc!(TraitLoc, id: Trait, container: ModuleId); impl_loc!(TraitLoc, id: Trait, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TraitAliasId(salsa::InternId); pub struct TraitAliasId(ra_salsa::InternId);
pub type TraitAliasLoc = ItemLoc<TraitAlias>; pub type TraitAliasLoc = ItemLoc<TraitAlias>;
impl_intern!(TraitAliasId, TraitAliasLoc, intern_trait_alias, lookup_intern_trait_alias); impl_intern!(TraitAliasId, TraitAliasLoc, intern_trait_alias, lookup_intern_trait_alias);
impl_loc!(TraitAliasLoc, id: TraitAlias, container: ModuleId); impl_loc!(TraitAliasLoc, id: TraitAlias, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TypeAliasId(salsa::InternId); pub struct TypeAliasId(ra_salsa::InternId);
type TypeAliasLoc = AssocItemLoc<TypeAlias>; type TypeAliasLoc = AssocItemLoc<TypeAlias>;
impl_intern!(TypeAliasId, TypeAliasLoc, intern_type_alias, lookup_intern_type_alias); impl_intern!(TypeAliasId, TypeAliasLoc, intern_type_alias, lookup_intern_type_alias);
impl_loc!(TypeAliasLoc, id: TypeAlias, container: ItemContainerId); impl_loc!(TypeAliasLoc, id: TypeAlias, container: ItemContainerId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct ImplId(salsa::InternId); pub struct ImplId(ra_salsa::InternId);
type ImplLoc = ItemLoc<Impl>; type ImplLoc = ItemLoc<Impl>;
impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl); impl_intern!(ImplId, ImplLoc, intern_impl, lookup_intern_impl);
impl_loc!(ImplLoc, id: Impl, container: ModuleId); impl_loc!(ImplLoc, id: Impl, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct UseId(salsa::InternId); pub struct UseId(ra_salsa::InternId);
type UseLoc = ItemLoc<Use>; type UseLoc = ItemLoc<Use>;
impl_intern!(UseId, UseLoc, intern_use, lookup_intern_use); impl_intern!(UseId, UseLoc, intern_use, lookup_intern_use);
impl_loc!(UseLoc, id: Use, container: ModuleId); impl_loc!(UseLoc, id: Use, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct ExternCrateId(salsa::InternId); pub struct ExternCrateId(ra_salsa::InternId);
type ExternCrateLoc = ItemLoc<ExternCrate>; type ExternCrateLoc = ItemLoc<ExternCrate>;
impl_intern!(ExternCrateId, ExternCrateLoc, intern_extern_crate, lookup_intern_extern_crate); impl_intern!(ExternCrateId, ExternCrateLoc, intern_extern_crate, lookup_intern_extern_crate);
impl_loc!(ExternCrateLoc, id: ExternCrate, container: ModuleId); impl_loc!(ExternCrateLoc, id: ExternCrate, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct ExternBlockId(salsa::InternId); pub struct ExternBlockId(ra_salsa::InternId);
type ExternBlockLoc = ItemLoc<ExternBlock>; type ExternBlockLoc = ItemLoc<ExternBlock>;
impl_intern!(ExternBlockId, ExternBlockLoc, intern_extern_block, lookup_intern_extern_block); impl_intern!(ExternBlockId, ExternBlockLoc, intern_extern_block, lookup_intern_extern_block);
impl_loc!(ExternBlockLoc, id: ExternBlock, container: ModuleId); impl_loc!(ExternBlockLoc, id: ExternBlock, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EnumVariantId(salsa::InternId); pub struct EnumVariantId(ra_salsa::InternId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct EnumVariantLoc { pub struct EnumVariantLoc {
@ -296,7 +296,7 @@ impl_intern!(EnumVariantId, EnumVariantLoc, intern_enum_variant, lookup_intern_e
impl_loc!(EnumVariantLoc, id: Variant, parent: EnumId); impl_loc!(EnumVariantLoc, id: Variant, parent: EnumId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct Macro2Id(salsa::InternId); pub struct Macro2Id(ra_salsa::InternId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Macro2Loc { pub struct Macro2Loc {
pub container: ModuleId, pub container: ModuleId,
@ -309,7 +309,7 @@ impl_intern!(Macro2Id, Macro2Loc, intern_macro2, lookup_intern_macro2);
impl_loc!(Macro2Loc, id: Macro2, container: ModuleId); impl_loc!(Macro2Loc, id: Macro2, container: ModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct MacroRulesId(salsa::InternId); pub struct MacroRulesId(ra_salsa::InternId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MacroRulesLoc { pub struct MacroRulesLoc {
pub container: ModuleId, pub container: ModuleId,
@ -338,7 +338,7 @@ pub enum MacroExpander {
BuiltInEager(EagerExpander), BuiltInEager(EagerExpander),
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct ProcMacroId(salsa::InternId); pub struct ProcMacroId(ra_salsa::InternId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ProcMacroLoc { pub struct ProcMacroLoc {
pub container: CrateRootModuleId, pub container: CrateRootModuleId,
@ -351,7 +351,7 @@ impl_intern!(ProcMacroId, ProcMacroLoc, intern_proc_macro, lookup_intern_proc_ma
impl_loc!(ProcMacroLoc, id: Function, container: CrateRootModuleId); impl_loc!(ProcMacroLoc, id: Function, container: CrateRootModuleId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct BlockId(salsa::InternId); pub struct BlockId(ra_salsa::InternId);
#[derive(Debug, Hash, PartialEq, Eq, Clone)] #[derive(Debug, Hash, PartialEq, Eq, Clone)]
pub struct BlockLoc { pub struct BlockLoc {
ast_id: AstId<ast::BlockExpr>, ast_id: AstId<ast::BlockExpr>,
@ -363,7 +363,7 @@ impl_intern!(BlockId, BlockLoc, intern_block, lookup_intern_block);
/// Id of the anonymous const block expression and patterns. This is very similar to `ClosureId` and /// Id of the anonymous const block expression and patterns. This is very similar to `ClosureId` and
/// shouldn't be a `DefWithBodyId` since its type inference is dependent on its parent. /// shouldn't be a `DefWithBodyId` since its type inference is dependent on its parent.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct ConstBlockId(salsa::InternId); pub struct ConstBlockId(ra_salsa::InternId);
impl_intern!(ConstBlockId, ConstBlockLoc, intern_anonymous_const, lookup_intern_anonymous_const); impl_intern!(ConstBlockId, ConstBlockLoc, intern_anonymous_const, lookup_intern_anonymous_const);
#[derive(Debug, Hash, PartialEq, Eq, Clone)] #[derive(Debug, Hash, PartialEq, Eq, Clone)]
@ -803,7 +803,7 @@ impl Clone for Box<dyn OpaqueInternableThing> {
/// length (like `[u8; 2 + 2]`). These constants are body owner and are a variant of `DefWithBodyId`. These /// length (like `[u8; 2 + 2]`). These constants are body owner and are a variant of `DefWithBodyId`. These
/// are not called `AnonymousConstId` to prevent confusion with [`ConstBlockId`]. /// are not called `AnonymousConstId` to prevent confusion with [`ConstBlockId`].
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct InTypeConstId(salsa::InternId); pub struct InTypeConstId(ra_salsa::InternId);
impl_intern!(InTypeConstId, InTypeConstLoc, intern_in_type_const, lookup_intern_in_type_const); impl_intern!(InTypeConstId, InTypeConstLoc, intern_in_type_const, lookup_intern_in_type_const);
// We would like to set `derive(PartialEq)` // We would like to set `derive(PartialEq)`

View file

@ -3,7 +3,7 @@
use std::{fmt, panic, sync::Mutex}; use std::{fmt, panic, sync::Mutex};
use base_db::{ use base_db::{
salsa::{self, Durability}, ra_salsa::{self, Durability},
AnchoredPath, CrateId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast, AnchoredPath, CrateId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
}; };
use hir_expand::{db::ExpandDatabase, files::FilePosition, InFile}; use hir_expand::{db::ExpandDatabase, files::FilePosition, InFile};
@ -18,7 +18,7 @@ use crate::{
LocalModuleId, Lookup, ModuleDefId, ModuleId, LocalModuleId, Lookup, ModuleDefId, ModuleId,
}; };
#[salsa::database( #[ra_salsa::database(
base_db::SourceRootDatabaseStorage, base_db::SourceRootDatabaseStorage,
base_db::SourceDatabaseStorage, base_db::SourceDatabaseStorage,
hir_expand::db::ExpandDatabaseStorage, hir_expand::db::ExpandDatabaseStorage,
@ -26,8 +26,8 @@ use crate::{
crate::db::DefDatabaseStorage crate::db::DefDatabaseStorage
)] )]
pub(crate) struct TestDB { pub(crate) struct TestDB {
storage: salsa::Storage<TestDB>, storage: ra_salsa::Storage<TestDB>,
events: Mutex<Option<Vec<salsa::Event>>>, events: Mutex<Option<Vec<ra_salsa::Event>>>,
} }
impl Default for TestDB { impl Default for TestDB {
@ -51,8 +51,8 @@ impl Upcast<dyn DefDatabase> for TestDB {
} }
} }
impl salsa::Database for TestDB { impl ra_salsa::Database for TestDB {
fn salsa_event(&self, event: salsa::Event) { fn salsa_event(&self, event: ra_salsa::Event) {
let mut events = self.events.lock().unwrap(); let mut events = self.events.lock().unwrap();
if let Some(events) = &mut *events { if let Some(events) = &mut *events {
events.push(event); events.push(event);
@ -215,7 +215,7 @@ impl TestDB {
None None
} }
pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<ra_salsa::Event> {
*self.events.lock().unwrap() = Some(Vec::new()); *self.events.lock().unwrap() = Some(Vec::new());
f(); f();
self.events.lock().unwrap().take().unwrap() self.events.lock().unwrap().take().unwrap()
@ -228,7 +228,7 @@ impl TestDB {
.filter_map(|e| match e.kind { .filter_map(|e| match e.kind {
// This is pretty horrible, but `Debug` is the only way to inspect // This is pretty horrible, but `Debug` is the only way to inspect
// QueryDescriptor at the moment. // QueryDescriptor at the moment.
salsa::EventKind::WillExecute { database_key } => { ra_salsa::EventKind::WillExecute { database_key } => {
Some(format!("{:?}", database_key.debug(self))) Some(format!("{:?}", database_key.debug(self)))
} }
_ => None, _ => None,

View file

@ -1,7 +1,7 @@
//! Defines a unit of change that can applied to the database to get the next //! Defines a unit of change that can applied to the database to get the next
//! state. Changes are transactional. //! state. Changes are transactional.
use base_db::{ use base_db::{
salsa::Durability, CrateGraph, CrateId, CrateWorkspaceData, FileChange, SourceRoot, ra_salsa::Durability, CrateGraph, CrateId, CrateWorkspaceData, FileChange, SourceRoot,
SourceRootDatabase, SourceRootDatabase,
}; };
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;

View file

@ -1,6 +1,6 @@
//! Defines database & queries for macro expansion. //! Defines database & queries for macro expansion.
use base_db::{salsa, CrateId, SourceDatabase}; use base_db::{ra_salsa, CrateId, SourceDatabase};
use either::Either; use either::Either;
use limit::Limit; use limit::Limit;
use mbe::MatchedArmIndex; use mbe::MatchedArmIndex;
@ -53,32 +53,32 @@ pub enum TokenExpander {
ProcMacro(CustomProcMacroExpander), ProcMacro(CustomProcMacroExpander),
} }
#[salsa::query_group(ExpandDatabaseStorage)] #[ra_salsa::query_group(ExpandDatabaseStorage)]
pub trait ExpandDatabase: SourceDatabase { pub trait ExpandDatabase: SourceDatabase {
/// The proc macros. /// The proc macros.
#[salsa::input] #[ra_salsa::input]
fn proc_macros(&self) -> Arc<ProcMacros>; fn proc_macros(&self) -> Arc<ProcMacros>;
fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>; fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
/// Main public API -- parses a hir file, not caring whether it's a real /// Main public API -- parses a hir file, not caring whether it's a real
/// file or a macro expansion. /// file or a macro expansion.
#[salsa::transparent] #[ra_salsa::transparent]
fn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode; fn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode;
/// Implementation for the macro case. /// Implementation for the macro case.
#[salsa::lru] #[ra_salsa::lru]
fn parse_macro_expansion( fn parse_macro_expansion(
&self, &self,
macro_file: MacroFileId, macro_file: MacroFileId,
) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)>; ) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)>;
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(SpanMap::new)] #[ra_salsa::invoke(SpanMap::new)]
fn span_map(&self, file_id: HirFileId) -> SpanMap; fn span_map(&self, file_id: HirFileId) -> SpanMap;
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(crate::span_map::expansion_span_map)] #[ra_salsa::invoke(crate::span_map::expansion_span_map)]
fn expansion_span_map(&self, file_id: MacroFileId) -> Arc<ExpansionSpanMap>; fn expansion_span_map(&self, file_id: MacroFileId) -> Arc<ExpansionSpanMap>;
#[salsa::invoke(crate::span_map::real_span_map)] #[ra_salsa::invoke(crate::span_map::real_span_map)]
fn real_span_map(&self, file_id: EditionedFileId) -> Arc<RealSpanMap>; fn real_span_map(&self, file_id: EditionedFileId) -> Arc<RealSpanMap>;
/// Macro ids. That's probably the tricksiest bit in rust-analyzer, and the /// Macro ids. That's probably the tricksiest bit in rust-analyzer, and the
@ -86,15 +86,15 @@ pub trait ExpandDatabase: SourceDatabase {
/// ///
/// We encode macro definitions into ids of macro calls, this what allows us /// We encode macro definitions into ids of macro calls, this what allows us
/// to be incremental. /// to be incremental.
#[salsa::interned] #[ra_salsa::interned]
fn intern_macro_call(&self, macro_call: MacroCallLoc) -> MacroCallId; fn intern_macro_call(&self, macro_call: MacroCallLoc) -> MacroCallId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_syntax_context(&self, ctx: SyntaxContextData) -> SyntaxContextId; fn intern_syntax_context(&self, ctx: SyntaxContextData) -> SyntaxContextId;
#[salsa::transparent] #[ra_salsa::transparent]
fn setup_syntax_context_root(&self) -> (); fn setup_syntax_context_root(&self) -> ();
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(crate::hygiene::dump_syntax_contexts)] #[ra_salsa::invoke(crate::hygiene::dump_syntax_contexts)]
fn dump_syntax_contexts(&self) -> String; fn dump_syntax_contexts(&self) -> String;
/// Lowers syntactic macro call to a token tree representation. That's a firewall /// Lowers syntactic macro call to a token tree representation. That's a firewall
@ -102,18 +102,18 @@ pub trait ExpandDatabase: SourceDatabase {
/// subtree. /// subtree.
#[deprecated = "calling this is incorrect, call `macro_arg_considering_derives` instead"] #[deprecated = "calling this is incorrect, call `macro_arg_considering_derives` instead"]
fn macro_arg(&self, id: MacroCallId) -> MacroArgResult; fn macro_arg(&self, id: MacroCallId) -> MacroArgResult;
#[salsa::transparent] #[ra_salsa::transparent]
fn macro_arg_considering_derives( fn macro_arg_considering_derives(
&self, &self,
id: MacroCallId, id: MacroCallId,
kind: &MacroCallKind, kind: &MacroCallKind,
) -> MacroArgResult; ) -> MacroArgResult;
/// Fetches the expander for this macro. /// Fetches the expander for this macro.
#[salsa::transparent] #[ra_salsa::transparent]
#[salsa::invoke(TokenExpander::macro_expander)] #[ra_salsa::invoke(TokenExpander::macro_expander)]
fn macro_expander(&self, id: MacroDefId) -> TokenExpander; fn macro_expander(&self, id: MacroDefId) -> TokenExpander;
/// Fetches (and compiles) the expander of this decl macro. /// Fetches (and compiles) the expander of this decl macro.
#[salsa::invoke(DeclarativeMacroExpander::expander)] #[ra_salsa::invoke(DeclarativeMacroExpander::expander)]
fn decl_macro_expander( fn decl_macro_expander(
&self, &self,
def_crate: CrateId, def_crate: CrateId,
@ -135,7 +135,7 @@ pub trait ExpandDatabase: SourceDatabase {
&self, &self,
macro_call: MacroCallId, macro_call: MacroCallId,
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>; ) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>;
#[salsa::transparent] #[ra_salsa::transparent]
fn syntax_context(&self, file: HirFileId) -> SyntaxContextId; fn syntax_context(&self, file: HirFileId) -> SyntaxContextId;
} }

View file

@ -97,7 +97,7 @@ fn apply_mark_internal(
call_id: MacroCallId, call_id: MacroCallId,
transparency: Transparency, transparency: Transparency,
) -> SyntaxContextId { ) -> SyntaxContextId {
use base_db::salsa; use base_db::ra_salsa;
let call_id = Some(call_id); let call_id = Some(call_id);
@ -107,7 +107,7 @@ fn apply_mark_internal(
if transparency >= Transparency::Opaque { if transparency >= Transparency::Opaque {
let parent = opaque; let parent = opaque;
opaque = salsa::plumbing::get_query_table::<InternSyntaxContextQuery>(db).get_or_insert( opaque = ra_salsa::plumbing::get_query_table::<InternSyntaxContextQuery>(db).get_or_insert(
(parent, call_id, transparency), (parent, call_id, transparency),
|new_opaque| SyntaxContextData { |new_opaque| SyntaxContextData {
outer_expn: call_id, outer_expn: call_id,
@ -122,7 +122,7 @@ fn apply_mark_internal(
if transparency >= Transparency::SemiTransparent { if transparency >= Transparency::SemiTransparent {
let parent = opaque_and_semitransparent; let parent = opaque_and_semitransparent;
opaque_and_semitransparent = opaque_and_semitransparent =
salsa::plumbing::get_query_table::<InternSyntaxContextQuery>(db).get_or_insert( ra_salsa::plumbing::get_query_table::<InternSyntaxContextQuery>(db).get_or_insert(
(parent, call_id, transparency), (parent, call_id, transparency),
|new_opaque_and_semitransparent| SyntaxContextData { |new_opaque_and_semitransparent| SyntaxContextData {
outer_expn: call_id, outer_expn: call_id,
@ -200,7 +200,7 @@ pub fn marks_rev(
pub(crate) fn dump_syntax_contexts(db: &dyn ExpandDatabase) -> String { pub(crate) fn dump_syntax_contexts(db: &dyn ExpandDatabase) -> String {
use crate::db::{InternMacroCallLookupQuery, InternSyntaxContextLookupQuery}; use crate::db::{InternMacroCallLookupQuery, InternSyntaxContextLookupQuery};
use base_db::salsa::debug::DebugQueryTable; use base_db::ra_salsa::debug::DebugQueryTable;
let mut s = String::from("Expansions:"); let mut s = String::from("Expansions:");
let mut entries = InternMacroCallLookupQuery.in_db(db).entries::<Vec<_>>(); let mut entries = InternMacroCallLookupQuery.in_db(db).entries::<Vec<_>>();

View file

@ -30,7 +30,7 @@ use triomphe::Arc;
use std::hash::Hash; use std::hash::Hash;
use base_db::{salsa::InternValueTrivial, CrateId}; use base_db::{ra_salsa::InternValueTrivial, CrateId};
use either::Either; use either::Either;
use span::{ use span::{
Edition, EditionedFileId, ErasedFileAstId, FileAstId, HirFileIdRepr, Span, SpanAnchor, Edition, EditionedFileId, ErasedFileAstId, FileAstId, HirFileIdRepr, Span, SpanAnchor,

View file

@ -1,6 +1,6 @@
//! Constant evaluation details //! Constant evaluation details
use base_db::{salsa::Cycle, CrateId}; use base_db::{ra_salsa::Cycle, CrateId};
use chalk_ir::{cast::Cast, BoundVar, DebruijnIndex}; use chalk_ir::{cast::Cast, BoundVar, DebruijnIndex};
use hir_def::{ use hir_def::{
body::Body, body::Body,

View file

@ -5,7 +5,7 @@ use std::sync;
use base_db::{ use base_db::{
impl_intern_key, impl_intern_key,
salsa::{self, InternValueTrivial}, ra_salsa::{self, InternValueTrivial},
CrateId, Upcast, CrateId, Upcast,
}; };
use hir_def::{ use hir_def::{
@ -30,22 +30,22 @@ use crate::{
}; };
use hir_expand::name::Name; use hir_expand::name::Name;
#[salsa::query_group(HirDatabaseStorage)] #[ra_salsa::query_group(HirDatabaseStorage)]
pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
#[salsa::invoke(crate::infer::infer_query)] #[ra_salsa::invoke(crate::infer::infer_query)]
fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>; fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
// region:mir // region:mir
#[salsa::invoke(crate::mir::mir_body_query)] #[ra_salsa::invoke(crate::mir::mir_body_query)]
#[salsa::cycle(crate::mir::mir_body_recover)] #[ra_salsa::cycle(crate::mir::mir_body_recover)]
fn mir_body(&self, def: DefWithBodyId) -> Result<Arc<MirBody>, MirLowerError>; fn mir_body(&self, def: DefWithBodyId) -> Result<Arc<MirBody>, MirLowerError>;
#[salsa::invoke(crate::mir::mir_body_for_closure_query)] #[ra_salsa::invoke(crate::mir::mir_body_for_closure_query)]
fn mir_body_for_closure(&self, def: ClosureId) -> Result<Arc<MirBody>, MirLowerError>; fn mir_body_for_closure(&self, def: ClosureId) -> Result<Arc<MirBody>, MirLowerError>;
#[salsa::invoke(crate::mir::monomorphized_mir_body_query)] #[ra_salsa::invoke(crate::mir::monomorphized_mir_body_query)]
#[salsa::cycle(crate::mir::monomorphized_mir_body_recover)] #[ra_salsa::cycle(crate::mir::monomorphized_mir_body_recover)]
fn monomorphized_mir_body( fn monomorphized_mir_body(
&self, &self,
def: DefWithBodyId, def: DefWithBodyId,
@ -53,7 +53,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
env: Arc<TraitEnvironment>, env: Arc<TraitEnvironment>,
) -> Result<Arc<MirBody>, MirLowerError>; ) -> Result<Arc<MirBody>, MirLowerError>;
#[salsa::invoke(crate::mir::monomorphized_mir_body_for_closure_query)] #[ra_salsa::invoke(crate::mir::monomorphized_mir_body_for_closure_query)]
fn monomorphized_mir_body_for_closure( fn monomorphized_mir_body_for_closure(
&self, &self,
def: ClosureId, def: ClosureId,
@ -61,12 +61,12 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
env: Arc<TraitEnvironment>, env: Arc<TraitEnvironment>,
) -> Result<Arc<MirBody>, MirLowerError>; ) -> Result<Arc<MirBody>, MirLowerError>;
#[salsa::invoke(crate::mir::borrowck_query)] #[ra_salsa::invoke(crate::mir::borrowck_query)]
#[salsa::lru] #[ra_salsa::lru]
fn borrowck(&self, def: DefWithBodyId) -> Result<Arc<[BorrowckResult]>, MirLowerError>; fn borrowck(&self, def: DefWithBodyId) -> Result<Arc<[BorrowckResult]>, MirLowerError>;
#[salsa::invoke(crate::consteval::const_eval_query)] #[ra_salsa::invoke(crate::consteval::const_eval_query)]
#[salsa::cycle(crate::consteval::const_eval_recover)] #[ra_salsa::cycle(crate::consteval::const_eval_recover)]
fn const_eval( fn const_eval(
&self, &self,
def: GeneralConstId, def: GeneralConstId,
@ -74,15 +74,15 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
trait_env: Option<Arc<TraitEnvironment>>, trait_env: Option<Arc<TraitEnvironment>>,
) -> Result<Const, ConstEvalError>; ) -> Result<Const, ConstEvalError>;
#[salsa::invoke(crate::consteval::const_eval_static_query)] #[ra_salsa::invoke(crate::consteval::const_eval_static_query)]
#[salsa::cycle(crate::consteval::const_eval_static_recover)] #[ra_salsa::cycle(crate::consteval::const_eval_static_recover)]
fn const_eval_static(&self, def: StaticId) -> Result<Const, ConstEvalError>; fn const_eval_static(&self, def: StaticId) -> Result<Const, ConstEvalError>;
#[salsa::invoke(crate::consteval::const_eval_discriminant_variant)] #[ra_salsa::invoke(crate::consteval::const_eval_discriminant_variant)]
#[salsa::cycle(crate::consteval::const_eval_discriminant_recover)] #[ra_salsa::cycle(crate::consteval::const_eval_discriminant_recover)]
fn const_eval_discriminant(&self, def: EnumVariantId) -> Result<i128, ConstEvalError>; fn const_eval_discriminant(&self, def: EnumVariantId) -> Result<i128, ConstEvalError>;
#[salsa::invoke(crate::method_resolution::lookup_impl_method_query)] #[ra_salsa::invoke(crate::method_resolution::lookup_impl_method_query)]
fn lookup_impl_method( fn lookup_impl_method(
&self, &self,
env: Arc<TraitEnvironment>, env: Arc<TraitEnvironment>,
@ -92,8 +92,8 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
// endregion:mir // endregion:mir
#[salsa::invoke(crate::layout::layout_of_adt_query)] #[ra_salsa::invoke(crate::layout::layout_of_adt_query)]
#[salsa::cycle(crate::layout::layout_of_adt_recover)] #[ra_salsa::cycle(crate::layout::layout_of_adt_recover)]
fn layout_of_adt( fn layout_of_adt(
&self, &self,
def: AdtId, def: AdtId,
@ -101,49 +101,49 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
env: Arc<TraitEnvironment>, env: Arc<TraitEnvironment>,
) -> Result<Arc<Layout>, LayoutError>; ) -> Result<Arc<Layout>, LayoutError>;
#[salsa::invoke(crate::layout::layout_of_ty_query)] #[ra_salsa::invoke(crate::layout::layout_of_ty_query)]
#[salsa::cycle(crate::layout::layout_of_ty_recover)] #[ra_salsa::cycle(crate::layout::layout_of_ty_recover)]
fn layout_of_ty(&self, ty: Ty, env: Arc<TraitEnvironment>) -> Result<Arc<Layout>, LayoutError>; fn layout_of_ty(&self, ty: Ty, env: Arc<TraitEnvironment>) -> Result<Arc<Layout>, LayoutError>;
#[salsa::invoke(crate::layout::target_data_layout_query)] #[ra_salsa::invoke(crate::layout::target_data_layout_query)]
fn target_data_layout(&self, krate: CrateId) -> Result<Arc<TargetDataLayout>, Arc<str>>; fn target_data_layout(&self, krate: CrateId) -> Result<Arc<TargetDataLayout>, Arc<str>>;
#[salsa::invoke(crate::dyn_compatibility::dyn_compatibility_of_trait_query)] #[ra_salsa::invoke(crate::dyn_compatibility::dyn_compatibility_of_trait_query)]
fn dyn_compatibility_of_trait(&self, trait_: TraitId) -> Option<DynCompatibilityViolation>; fn dyn_compatibility_of_trait(&self, trait_: TraitId) -> Option<DynCompatibilityViolation>;
#[salsa::invoke(crate::lower::ty_query)] #[ra_salsa::invoke(crate::lower::ty_query)]
#[salsa::cycle(crate::lower::ty_recover)] #[ra_salsa::cycle(crate::lower::ty_recover)]
fn ty(&self, def: TyDefId) -> Binders<Ty>; fn ty(&self, def: TyDefId) -> Binders<Ty>;
/// Returns the type of the value of the given constant, or `None` if the `ValueTyDefId` is /// Returns the type of the value of the given constant, or `None` if the `ValueTyDefId` is
/// a `StructId` or `EnumVariantId` with a record constructor. /// a `StructId` or `EnumVariantId` with a record constructor.
#[salsa::invoke(crate::lower::value_ty_query)] #[ra_salsa::invoke(crate::lower::value_ty_query)]
fn value_ty(&self, def: ValueTyDefId) -> Option<Binders<Ty>>; fn value_ty(&self, def: ValueTyDefId) -> Option<Binders<Ty>>;
#[salsa::invoke(crate::lower::impl_self_ty_query)] #[ra_salsa::invoke(crate::lower::impl_self_ty_query)]
#[salsa::cycle(crate::lower::impl_self_ty_recover)] #[ra_salsa::cycle(crate::lower::impl_self_ty_recover)]
fn impl_self_ty(&self, def: ImplId) -> Binders<Ty>; fn impl_self_ty(&self, def: ImplId) -> Binders<Ty>;
#[salsa::invoke(crate::lower::const_param_ty_query)] #[ra_salsa::invoke(crate::lower::const_param_ty_query)]
fn const_param_ty(&self, def: ConstParamId) -> Ty; fn const_param_ty(&self, def: ConstParamId) -> Ty;
#[salsa::invoke(crate::lower::impl_trait_query)] #[ra_salsa::invoke(crate::lower::impl_trait_query)]
fn impl_trait(&self, def: ImplId) -> Option<Binders<TraitRef>>; fn impl_trait(&self, def: ImplId) -> Option<Binders<TraitRef>>;
#[salsa::invoke(crate::lower::field_types_query)] #[ra_salsa::invoke(crate::lower::field_types_query)]
fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Binders<Ty>>>; fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Binders<Ty>>>;
#[salsa::invoke(crate::lower::callable_item_sig)] #[ra_salsa::invoke(crate::lower::callable_item_sig)]
fn callable_item_signature(&self, def: CallableDefId) -> PolyFnSig; fn callable_item_signature(&self, def: CallableDefId) -> PolyFnSig;
#[salsa::invoke(crate::lower::return_type_impl_traits)] #[ra_salsa::invoke(crate::lower::return_type_impl_traits)]
fn return_type_impl_traits(&self, def: FunctionId) -> Option<Arc<Binders<ImplTraits>>>; fn return_type_impl_traits(&self, def: FunctionId) -> Option<Arc<Binders<ImplTraits>>>;
#[salsa::invoke(crate::lower::type_alias_impl_traits)] #[ra_salsa::invoke(crate::lower::type_alias_impl_traits)]
fn type_alias_impl_traits(&self, def: TypeAliasId) -> Option<Arc<Binders<ImplTraits>>>; fn type_alias_impl_traits(&self, def: TypeAliasId) -> Option<Arc<Binders<ImplTraits>>>;
#[salsa::invoke(crate::lower::generic_predicates_for_param_query)] #[ra_salsa::invoke(crate::lower::generic_predicates_for_param_query)]
#[salsa::cycle(crate::lower::generic_predicates_for_param_recover)] #[ra_salsa::cycle(crate::lower::generic_predicates_for_param_recover)]
fn generic_predicates_for_param( fn generic_predicates_for_param(
&self, &self,
def: GenericDefId, def: GenericDefId,
@ -151,118 +151,118 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
assoc_name: Option<Name>, assoc_name: Option<Name>,
) -> GenericPredicates; ) -> GenericPredicates;
#[salsa::invoke(crate::lower::generic_predicates_query)] #[ra_salsa::invoke(crate::lower::generic_predicates_query)]
fn generic_predicates(&self, def: GenericDefId) -> GenericPredicates; fn generic_predicates(&self, def: GenericDefId) -> GenericPredicates;
#[salsa::invoke(crate::lower::generic_predicates_without_parent_query)] #[ra_salsa::invoke(crate::lower::generic_predicates_without_parent_query)]
fn generic_predicates_without_parent(&self, def: GenericDefId) -> GenericPredicates; fn generic_predicates_without_parent(&self, def: GenericDefId) -> GenericPredicates;
#[salsa::invoke(crate::lower::trait_environment_for_body_query)] #[ra_salsa::invoke(crate::lower::trait_environment_for_body_query)]
#[salsa::transparent] #[ra_salsa::transparent]
fn trait_environment_for_body(&self, def: DefWithBodyId) -> Arc<TraitEnvironment>; fn trait_environment_for_body(&self, def: DefWithBodyId) -> Arc<TraitEnvironment>;
#[salsa::invoke(crate::lower::trait_environment_query)] #[ra_salsa::invoke(crate::lower::trait_environment_query)]
fn trait_environment(&self, def: GenericDefId) -> Arc<TraitEnvironment>; fn trait_environment(&self, def: GenericDefId) -> Arc<TraitEnvironment>;
#[salsa::invoke(crate::lower::generic_defaults_query)] #[ra_salsa::invoke(crate::lower::generic_defaults_query)]
#[salsa::cycle(crate::lower::generic_defaults_recover)] #[ra_salsa::cycle(crate::lower::generic_defaults_recover)]
fn generic_defaults(&self, def: GenericDefId) -> GenericDefaults; fn generic_defaults(&self, def: GenericDefId) -> GenericDefaults;
#[salsa::invoke(InherentImpls::inherent_impls_in_crate_query)] #[ra_salsa::invoke(InherentImpls::inherent_impls_in_crate_query)]
fn inherent_impls_in_crate(&self, krate: CrateId) -> Arc<InherentImpls>; fn inherent_impls_in_crate(&self, krate: CrateId) -> Arc<InherentImpls>;
#[salsa::invoke(InherentImpls::inherent_impls_in_block_query)] #[ra_salsa::invoke(InherentImpls::inherent_impls_in_block_query)]
fn inherent_impls_in_block(&self, block: BlockId) -> Option<Arc<InherentImpls>>; fn inherent_impls_in_block(&self, block: BlockId) -> Option<Arc<InherentImpls>>;
/// Collects all crates in the dependency graph that have impls for the /// Collects all crates in the dependency graph that have impls for the
/// given fingerprint. This is only used for primitive types and types /// given fingerprint. This is only used for primitive types and types
/// annotated with `rustc_has_incoherent_inherent_impls`; for other types /// annotated with `rustc_has_incoherent_inherent_impls`; for other types
/// we just look at the crate where the type is defined. /// we just look at the crate where the type is defined.
#[salsa::invoke(crate::method_resolution::incoherent_inherent_impl_crates)] #[ra_salsa::invoke(crate::method_resolution::incoherent_inherent_impl_crates)]
fn incoherent_inherent_impl_crates( fn incoherent_inherent_impl_crates(
&self, &self,
krate: CrateId, krate: CrateId,
fp: TyFingerprint, fp: TyFingerprint,
) -> SmallVec<[CrateId; 2]>; ) -> SmallVec<[CrateId; 2]>;
#[salsa::invoke(TraitImpls::trait_impls_in_crate_query)] #[ra_salsa::invoke(TraitImpls::trait_impls_in_crate_query)]
fn trait_impls_in_crate(&self, krate: CrateId) -> Arc<TraitImpls>; fn trait_impls_in_crate(&self, krate: CrateId) -> Arc<TraitImpls>;
#[salsa::invoke(TraitImpls::trait_impls_in_block_query)] #[ra_salsa::invoke(TraitImpls::trait_impls_in_block_query)]
fn trait_impls_in_block(&self, block: BlockId) -> Option<Arc<TraitImpls>>; fn trait_impls_in_block(&self, block: BlockId) -> Option<Arc<TraitImpls>>;
#[salsa::invoke(TraitImpls::trait_impls_in_deps_query)] #[ra_salsa::invoke(TraitImpls::trait_impls_in_deps_query)]
fn trait_impls_in_deps(&self, krate: CrateId) -> Arc<[Arc<TraitImpls>]>; fn trait_impls_in_deps(&self, krate: CrateId) -> Arc<[Arc<TraitImpls>]>;
// Interned IDs for Chalk integration // Interned IDs for Chalk integration
#[salsa::interned] #[ra_salsa::interned]
fn intern_callable_def(&self, callable_def: CallableDefId) -> InternedCallableDefId; fn intern_callable_def(&self, callable_def: CallableDefId) -> InternedCallableDefId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_type_or_const_param_id( fn intern_type_or_const_param_id(
&self, &self,
param_id: TypeOrConstParamId, param_id: TypeOrConstParamId,
) -> InternedTypeOrConstParamId; ) -> InternedTypeOrConstParamId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_lifetime_param_id(&self, param_id: LifetimeParamId) -> InternedLifetimeParamId; fn intern_lifetime_param_id(&self, param_id: LifetimeParamId) -> InternedLifetimeParamId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_impl_trait_id(&self, id: ImplTraitId) -> InternedOpaqueTyId; fn intern_impl_trait_id(&self, id: ImplTraitId) -> InternedOpaqueTyId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_closure(&self, id: InternedClosure) -> InternedClosureId; fn intern_closure(&self, id: InternedClosure) -> InternedClosureId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_coroutine(&self, id: InternedCoroutine) -> InternedCoroutineId; fn intern_coroutine(&self, id: InternedCoroutine) -> InternedCoroutineId;
#[salsa::invoke(chalk_db::associated_ty_data_query)] #[ra_salsa::invoke(chalk_db::associated_ty_data_query)]
fn associated_ty_data( fn associated_ty_data(
&self, &self,
id: chalk_db::AssocTypeId, id: chalk_db::AssocTypeId,
) -> sync::Arc<chalk_db::AssociatedTyDatum>; ) -> sync::Arc<chalk_db::AssociatedTyDatum>;
#[salsa::invoke(chalk_db::trait_datum_query)] #[ra_salsa::invoke(chalk_db::trait_datum_query)]
fn trait_datum( fn trait_datum(
&self, &self,
krate: CrateId, krate: CrateId,
trait_id: chalk_db::TraitId, trait_id: chalk_db::TraitId,
) -> sync::Arc<chalk_db::TraitDatum>; ) -> sync::Arc<chalk_db::TraitDatum>;
#[salsa::invoke(chalk_db::adt_datum_query)] #[ra_salsa::invoke(chalk_db::adt_datum_query)]
fn adt_datum( fn adt_datum(
&self, &self,
krate: CrateId, krate: CrateId,
struct_id: chalk_db::AdtId, struct_id: chalk_db::AdtId,
) -> sync::Arc<chalk_db::AdtDatum>; ) -> sync::Arc<chalk_db::AdtDatum>;
#[salsa::invoke(chalk_db::impl_datum_query)] #[ra_salsa::invoke(chalk_db::impl_datum_query)]
fn impl_datum( fn impl_datum(
&self, &self,
krate: CrateId, krate: CrateId,
impl_id: chalk_db::ImplId, impl_id: chalk_db::ImplId,
) -> sync::Arc<chalk_db::ImplDatum>; ) -> sync::Arc<chalk_db::ImplDatum>;
#[salsa::invoke(chalk_db::fn_def_datum_query)] #[ra_salsa::invoke(chalk_db::fn_def_datum_query)]
fn fn_def_datum(&self, fn_def_id: FnDefId) -> sync::Arc<chalk_db::FnDefDatum>; fn fn_def_datum(&self, fn_def_id: FnDefId) -> sync::Arc<chalk_db::FnDefDatum>;
#[salsa::invoke(chalk_db::fn_def_variance_query)] #[ra_salsa::invoke(chalk_db::fn_def_variance_query)]
fn fn_def_variance(&self, fn_def_id: FnDefId) -> chalk_db::Variances; fn fn_def_variance(&self, fn_def_id: FnDefId) -> chalk_db::Variances;
#[salsa::invoke(chalk_db::adt_variance_query)] #[ra_salsa::invoke(chalk_db::adt_variance_query)]
fn adt_variance(&self, adt_id: chalk_db::AdtId) -> chalk_db::Variances; fn adt_variance(&self, adt_id: chalk_db::AdtId) -> chalk_db::Variances;
#[salsa::invoke(chalk_db::associated_ty_value_query)] #[ra_salsa::invoke(chalk_db::associated_ty_value_query)]
fn associated_ty_value( fn associated_ty_value(
&self, &self,
krate: CrateId, krate: CrateId,
id: chalk_db::AssociatedTyValueId, id: chalk_db::AssociatedTyValueId,
) -> sync::Arc<chalk_db::AssociatedTyValue>; ) -> sync::Arc<chalk_db::AssociatedTyValue>;
#[salsa::invoke(crate::traits::normalize_projection_query)] #[ra_salsa::invoke(crate::traits::normalize_projection_query)]
#[salsa::transparent] #[ra_salsa::transparent]
fn normalize_projection( fn normalize_projection(
&self, &self,
projection: crate::ProjectionTy, projection: crate::ProjectionTy,
env: Arc<TraitEnvironment>, env: Arc<TraitEnvironment>,
) -> Ty; ) -> Ty;
#[salsa::invoke(crate::traits::trait_solve_query)] #[ra_salsa::invoke(crate::traits::trait_solve_query)]
fn trait_solve( fn trait_solve(
&self, &self,
krate: CrateId, krate: CrateId,
@ -270,7 +270,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
goal: crate::Canonical<crate::InEnvironment<crate::Goal>>, goal: crate::Canonical<crate::InEnvironment<crate::Goal>>,
) -> Option<crate::Solution>; ) -> Option<crate::Solution>;
#[salsa::invoke(chalk_db::program_clauses_for_chalk_env_query)] #[ra_salsa::invoke(chalk_db::program_clauses_for_chalk_env_query)]
fn program_clauses_for_chalk_env( fn program_clauses_for_chalk_env(
&self, &self,
krate: CrateId, krate: CrateId,
@ -285,23 +285,23 @@ fn hir_database_is_dyn_compatible() {
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InternedTypeOrConstParamId(salsa::InternId); pub struct InternedTypeOrConstParamId(ra_salsa::InternId);
impl_intern_key!(InternedTypeOrConstParamId); impl_intern_key!(InternedTypeOrConstParamId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InternedLifetimeParamId(salsa::InternId); pub struct InternedLifetimeParamId(ra_salsa::InternId);
impl_intern_key!(InternedLifetimeParamId); impl_intern_key!(InternedLifetimeParamId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InternedConstParamId(salsa::InternId); pub struct InternedConstParamId(ra_salsa::InternId);
impl_intern_key!(InternedConstParamId); impl_intern_key!(InternedConstParamId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InternedOpaqueTyId(salsa::InternId); pub struct InternedOpaqueTyId(ra_salsa::InternId);
impl_intern_key!(InternedOpaqueTyId); impl_intern_key!(InternedOpaqueTyId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InternedClosureId(salsa::InternId); pub struct InternedClosureId(ra_salsa::InternId);
impl_intern_key!(InternedClosureId); impl_intern_key!(InternedClosureId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -310,7 +310,7 @@ pub struct InternedClosure(pub DefWithBodyId, pub ExprId);
impl InternValueTrivial for InternedClosure {} impl InternValueTrivial for InternedClosure {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InternedCoroutineId(salsa::InternId); pub struct InternedCoroutineId(ra_salsa::InternId);
impl_intern_key!(InternedCoroutineId); impl_intern_key!(InternedCoroutineId);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@ -320,5 +320,5 @@ impl InternValueTrivial for InternedCoroutine {}
/// This exists just for Chalk, because Chalk just has a single `FnDefId` where /// This exists just for Chalk, because Chalk just has a single `FnDefId` where
/// we have different IDs for struct and enum variant constructors. /// we have different IDs for struct and enum variant constructors.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct InternedCallableDefId(salsa::InternId); pub struct InternedCallableDefId(ra_salsa::InternId);
impl_intern_key!(InternedCallableDefId); impl_intern_key!(InternedCallableDefId);

View file

@ -8,7 +8,7 @@ use crate::{
ProgramClauseData, ProgramClauses, ProjectionTy, QuantifiedWhereClause, QuantifiedWhereClauses, ProgramClauseData, ProgramClauses, ProjectionTy, QuantifiedWhereClause, QuantifiedWhereClauses,
Substitution, Ty, TyData, TyKind, VariableKind, VariableKinds, Substitution, Ty, TyData, TyKind, VariableKind, VariableKinds,
}; };
use base_db::salsa::InternId; use base_db::ra_salsa::InternId;
use chalk_ir::{ProgramClauseImplication, SeparatorTraitRef, Variance}; use chalk_ir::{ProgramClauseImplication, SeparatorTraitRef, Variance};
use hir_def::TypeAliasId; use hir_def::TypeAliasId;
use intern::{impl_internable, Interned}; use intern::{impl_internable, Interned};

View file

@ -2,7 +2,7 @@
use std::fmt; use std::fmt;
use base_db::salsa::Cycle; use base_db::ra_salsa::Cycle;
use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy}; use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy};
use hir_def::{ use hir_def::{
layout::{ layout::{

View file

@ -2,7 +2,7 @@
use std::{cmp, ops::Bound}; use std::{cmp, ops::Bound};
use base_db::salsa::Cycle; use base_db::ra_salsa::Cycle;
use hir_def::{ use hir_def::{
data::adt::VariantData, data::adt::VariantData,
layout::{Integer, ReprOptions, TargetDataLayout}, layout::{Integer, ReprOptions, TargetDataLayout},

View file

@ -56,7 +56,7 @@ use std::{
hash::{BuildHasherDefault, Hash}, hash::{BuildHasherDefault, Hash},
}; };
use base_db::salsa::InternValueTrivial; use base_db::ra_salsa::InternValueTrivial;
use chalk_ir::{ use chalk_ir::{
fold::{Shift, TypeFoldable}, fold::{Shift, TypeFoldable},
interner::HasInterner, interner::HasInterner,

View file

@ -11,7 +11,7 @@ use std::{
ops::{self, Not as _}, ops::{self, Not as _},
}; };
use base_db::{salsa::Cycle, CrateId}; use base_db::{ra_salsa::Cycle, CrateId};
use chalk_ir::{ use chalk_ir::{
cast::Cast, cast::Cast,
fold::{Shift, TypeFoldable}, fold::{Shift, TypeFoldable},

View file

@ -5,7 +5,7 @@
use chalk_solve::rust_ir; use chalk_solve::rust_ir;
use base_db::salsa::{self, InternKey}; use base_db::ra_salsa::{self, InternKey};
use hir_def::{LifetimeParamId, TraitId, TypeAliasId, TypeOrConstParamId}; use hir_def::{LifetimeParamId, TraitId, TypeAliasId, TypeOrConstParamId};
use crate::{ use crate::{
@ -116,24 +116,24 @@ impl From<crate::db::InternedCoroutineId> for chalk_ir::CoroutineId<Interner> {
} }
pub fn to_foreign_def_id(id: TypeAliasId) -> ForeignDefId { pub fn to_foreign_def_id(id: TypeAliasId) -> ForeignDefId {
chalk_ir::ForeignDefId(salsa::InternKey::as_intern_id(&id)) chalk_ir::ForeignDefId(ra_salsa::InternKey::as_intern_id(&id))
} }
pub fn from_foreign_def_id(id: ForeignDefId) -> TypeAliasId { pub fn from_foreign_def_id(id: ForeignDefId) -> TypeAliasId {
salsa::InternKey::from_intern_id(id.0) ra_salsa::InternKey::from_intern_id(id.0)
} }
pub fn to_assoc_type_id(id: TypeAliasId) -> AssocTypeId { pub fn to_assoc_type_id(id: TypeAliasId) -> AssocTypeId {
chalk_ir::AssocTypeId(salsa::InternKey::as_intern_id(&id)) chalk_ir::AssocTypeId(ra_salsa::InternKey::as_intern_id(&id))
} }
pub fn from_assoc_type_id(id: AssocTypeId) -> TypeAliasId { pub fn from_assoc_type_id(id: AssocTypeId) -> TypeAliasId {
salsa::InternKey::from_intern_id(id.0) ra_salsa::InternKey::from_intern_id(id.0)
} }
pub fn from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> TypeOrConstParamId { pub fn from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> TypeOrConstParamId {
assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT); assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
let interned_id = salsa::InternKey::from_intern_id(salsa::InternId::from(idx.idx)); let interned_id = ra_salsa::InternKey::from_intern_id(ra_salsa::InternId::from(idx.idx));
db.lookup_intern_type_or_const_param_id(interned_id) db.lookup_intern_type_or_const_param_id(interned_id)
} }
@ -141,13 +141,13 @@ pub fn to_placeholder_idx(db: &dyn HirDatabase, id: TypeOrConstParamId) -> Place
let interned_id = db.intern_type_or_const_param_id(id); let interned_id = db.intern_type_or_const_param_id(id);
PlaceholderIndex { PlaceholderIndex {
ui: chalk_ir::UniverseIndex::ROOT, ui: chalk_ir::UniverseIndex::ROOT,
idx: salsa::InternKey::as_intern_id(&interned_id).as_usize(), idx: ra_salsa::InternKey::as_intern_id(&interned_id).as_usize(),
} }
} }
pub fn lt_from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> LifetimeParamId { pub fn lt_from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> LifetimeParamId {
assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT); assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
let interned_id = salsa::InternKey::from_intern_id(salsa::InternId::from(idx.idx)); let interned_id = ra_salsa::InternKey::from_intern_id(ra_salsa::InternId::from(idx.idx));
db.lookup_intern_lifetime_param_id(interned_id) db.lookup_intern_lifetime_param_id(interned_id)
} }
@ -155,14 +155,14 @@ pub fn lt_to_placeholder_idx(db: &dyn HirDatabase, id: LifetimeParamId) -> Place
let interned_id = db.intern_lifetime_param_id(id); let interned_id = db.intern_lifetime_param_id(id);
PlaceholderIndex { PlaceholderIndex {
ui: chalk_ir::UniverseIndex::ROOT, ui: chalk_ir::UniverseIndex::ROOT,
idx: salsa::InternKey::as_intern_id(&interned_id).as_usize(), idx: ra_salsa::InternKey::as_intern_id(&interned_id).as_usize(),
} }
} }
pub fn to_chalk_trait_id(id: TraitId) -> ChalkTraitId { pub fn to_chalk_trait_id(id: TraitId) -> ChalkTraitId {
chalk_ir::TraitId(salsa::InternKey::as_intern_id(&id)) chalk_ir::TraitId(ra_salsa::InternKey::as_intern_id(&id))
} }
pub fn from_chalk_trait_id(id: ChalkTraitId) -> TraitId { pub fn from_chalk_trait_id(id: ChalkTraitId) -> TraitId {
salsa::InternKey::from_intern_id(id.0) ra_salsa::InternKey::from_intern_id(id.0)
} }

View file

@ -2,7 +2,7 @@
use std::{fmt::Write, iter, mem}; use std::{fmt::Write, iter, mem};
use base_db::salsa::Cycle; use base_db::ra_salsa::Cycle;
use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind}; use chalk_ir::{BoundVar, ConstData, DebruijnIndex, TyKind};
use hir_def::{ use hir_def::{
body::Body, body::Body,

View file

@ -9,7 +9,7 @@
use std::mem; use std::mem;
use base_db::salsa::Cycle; use base_db::ra_salsa::Cycle;
use chalk_ir::{ use chalk_ir::{
fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}, fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable},
ConstData, DebruijnIndex, ConstData, DebruijnIndex,

View file

@ -3,7 +3,7 @@
use std::{fmt, panic, sync::Mutex}; use std::{fmt, panic, sync::Mutex};
use base_db::{ use base_db::{
salsa::{self, Durability}, ra_salsa::{self, Durability},
AnchoredPath, CrateId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast, AnchoredPath, CrateId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
}; };
use hir_def::{db::DefDatabase, ModuleId}; use hir_def::{db::DefDatabase, ModuleId};
@ -14,7 +14,7 @@ use syntax::TextRange;
use test_utils::extract_annotations; use test_utils::extract_annotations;
use triomphe::Arc; use triomphe::Arc;
#[salsa::database( #[ra_salsa::database(
base_db::SourceRootDatabaseStorage, base_db::SourceRootDatabaseStorage,
base_db::SourceDatabaseStorage, base_db::SourceDatabaseStorage,
hir_expand::db::ExpandDatabaseStorage, hir_expand::db::ExpandDatabaseStorage,
@ -23,8 +23,8 @@ use triomphe::Arc;
crate::db::HirDatabaseStorage crate::db::HirDatabaseStorage
)] )]
pub(crate) struct TestDB { pub(crate) struct TestDB {
storage: salsa::Storage<TestDB>, storage: ra_salsa::Storage<TestDB>,
events: Mutex<Option<Vec<salsa::Event>>>, events: Mutex<Option<Vec<ra_salsa::Event>>>,
} }
impl Default for TestDB { impl Default for TestDB {
@ -54,8 +54,8 @@ impl Upcast<dyn DefDatabase> for TestDB {
} }
} }
impl salsa::Database for TestDB { impl ra_salsa::Database for TestDB {
fn salsa_event(&self, event: salsa::Event) { fn salsa_event(&self, event: ra_salsa::Event) {
let mut events = self.events.lock().unwrap(); let mut events = self.events.lock().unwrap();
if let Some(events) = &mut *events { if let Some(events) = &mut *events {
events.push(event); events.push(event);
@ -63,9 +63,9 @@ impl salsa::Database for TestDB {
} }
} }
impl salsa::ParallelDatabase for TestDB { impl ra_salsa::ParallelDatabase for TestDB {
fn snapshot(&self) -> salsa::Snapshot<TestDB> { fn snapshot(&self) -> ra_salsa::Snapshot<TestDB> {
salsa::Snapshot::new(TestDB { ra_salsa::Snapshot::new(TestDB {
storage: self.storage.snapshot(), storage: self.storage.snapshot(),
events: Default::default(), events: Default::default(),
}) })
@ -128,7 +128,7 @@ impl TestDB {
} }
impl TestDB { impl TestDB {
pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<ra_salsa::Event> {
*self.events.lock().unwrap() = Some(Vec::new()); *self.events.lock().unwrap() = Some(Vec::new());
f(); f();
self.events.lock().unwrap().take().unwrap() self.events.lock().unwrap().take().unwrap()
@ -141,7 +141,7 @@ impl TestDB {
.filter_map(|e| match e.kind { .filter_map(|e| match e.kind {
// This is pretty horrible, but `Debug` is the only way to inspect // This is pretty horrible, but `Debug` is the only way to inspect
// QueryDescriptor at the moment. // QueryDescriptor at the moment.
salsa::EventKind::WillExecute { database_key } => { ra_salsa::EventKind::WillExecute { database_key } => {
Some(format!("{:?}", database_key.debug(self))) Some(format!("{:?}", database_key.debug(self)))
} }
_ => None, _ => None,

View file

@ -1,4 +1,4 @@
use base_db::salsa::InternKey; use base_db::ra_salsa::InternKey;
use expect_test::{expect, Expect}; use expect_test::{expect, Expect};
use hir_def::db::DefDatabase; use hir_def::db::DefDatabase;
use hir_expand::files::InFileWrapper; use hir_expand::files::InFileWrapper;

View file

@ -1,7 +1,7 @@
//! Applies changes to the IDE state transactionally. //! Applies changes to the IDE state transactionally.
use base_db::{ use base_db::{
salsa::{ ra_salsa::{
debug::{DebugQueryTable, TableEntry}, debug::{DebugQueryTable, TableEntry},
Database, Durability, Query, QueryTable, Database, Durability, Query, QueryTable,
}, },

View file

@ -48,7 +48,7 @@ pub use hir::ChangeWithProcMacros;
use std::{fmt, mem::ManuallyDrop}; use std::{fmt, mem::ManuallyDrop};
use base_db::{ use base_db::{
salsa::{self, Durability}, ra_salsa::{self, Durability},
AnchoredPath, CrateId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast, AnchoredPath, CrateId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
DEFAULT_FILE_TEXT_LRU_CAP, DEFAULT_FILE_TEXT_LRU_CAP,
}; };
@ -74,7 +74,7 @@ pub type FxIndexMap<K, V> =
pub type FilePosition = FilePositionWrapper<FileId>; pub type FilePosition = FilePositionWrapper<FileId>;
pub type FileRange = FileRangeWrapper<FileId>; pub type FileRange = FileRangeWrapper<FileId>;
#[salsa::database( #[ra_salsa::database(
base_db::SourceRootDatabaseStorage, base_db::SourceRootDatabaseStorage,
base_db::SourceDatabaseStorage, base_db::SourceDatabaseStorage,
hir::db::ExpandDatabaseStorage, hir::db::ExpandDatabaseStorage,
@ -89,7 +89,7 @@ pub struct RootDatabase {
// `&RootDatabase -> &dyn OtherDatabase` cast will instantiate its drop glue in the vtable, // `&RootDatabase -> &dyn OtherDatabase` cast will instantiate its drop glue in the vtable,
// which duplicates `Weak::drop` and `Arc::drop` tens of thousands of times, which makes // which duplicates `Weak::drop` and `Arc::drop` tens of thousands of times, which makes
// compile times of all `ide_*` and downstream crates suffer greatly. // compile times of all `ide_*` and downstream crates suffer greatly.
storage: ManuallyDrop<salsa::Storage<RootDatabase>>, storage: ManuallyDrop<ra_salsa::Storage<RootDatabase>>,
} }
impl Drop for RootDatabase { impl Drop for RootDatabase {
@ -134,7 +134,7 @@ impl FileLoader for RootDatabase {
} }
} }
impl salsa::Database for RootDatabase {} impl ra_salsa::Database for RootDatabase {}
impl Default for RootDatabase { impl Default for RootDatabase {
fn default() -> RootDatabase { fn default() -> RootDatabase {
@ -144,7 +144,7 @@ impl Default for RootDatabase {
impl RootDatabase { impl RootDatabase {
pub fn new(lru_capacity: Option<u16>) -> RootDatabase { pub fn new(lru_capacity: Option<u16>) -> RootDatabase {
let mut db = RootDatabase { storage: ManuallyDrop::new(salsa::Storage::default()) }; let mut db = RootDatabase { storage: ManuallyDrop::new(ra_salsa::Storage::default()) };
db.set_crate_graph_with_durability(Default::default(), Durability::HIGH); db.set_crate_graph_with_durability(Default::default(), Durability::HIGH);
db.set_proc_macros_with_durability(Default::default(), Durability::HIGH); db.set_proc_macros_with_durability(Default::default(), Durability::HIGH);
db.set_local_roots_with_durability(Default::default(), Durability::HIGH); db.set_local_roots_with_durability(Default::default(), Durability::HIGH);
@ -195,13 +195,15 @@ impl RootDatabase {
} }
} }
impl salsa::ParallelDatabase for RootDatabase { impl ra_salsa::ParallelDatabase for RootDatabase {
fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { fn snapshot(&self) -> ra_salsa::Snapshot<RootDatabase> {
salsa::Snapshot::new(RootDatabase { storage: ManuallyDrop::new(self.storage.snapshot()) }) ra_salsa::Snapshot::new(RootDatabase {
storage: ManuallyDrop::new(self.storage.snapshot()),
})
} }
} }
#[salsa::query_group(LineIndexDatabaseStorage)] #[ra_salsa::query_group(LineIndexDatabaseStorage)]
pub trait LineIndexDatabase: base_db::SourceDatabase { pub trait LineIndexDatabase: base_db::SourceDatabase {
fn line_index(&self, file_id: FileId) -> Arc<LineIndex>; fn line_index(&self, file_id: FileId) -> Arc<LineIndex>;
} }

View file

@ -10,7 +10,7 @@ use hir::db::DefDatabase;
use crate::{ use crate::{
base_db::{ base_db::{
salsa::{Database, ParallelDatabase, Snapshot}, ra_salsa::{Database, ParallelDatabase, Snapshot},
Cancelled, CrateId, SourceDatabase, SourceRootDatabase, Cancelled, CrateId, SourceDatabase, SourceRootDatabase,
}, },
symbol_index::SymbolsDatabase, symbol_index::SymbolsDatabase,

View file

@ -7,7 +7,7 @@
use std::mem; use std::mem;
use std::{cell::LazyCell, cmp::Reverse}; use std::{cell::LazyCell, cmp::Reverse};
use base_db::{salsa::Database, SourceDatabase, SourceRootDatabase}; use base_db::{ra_salsa::Database, SourceDatabase, SourceRootDatabase};
use either::Either; use either::Either;
use hir::{ use hir::{
sym, Adt, AsAssocItem, DefWithBody, FileRange, FileRangeWrapper, HasAttrs, HasContainer, sym, Adt, AsAssocItem, DefWithBody, FileRange, FileRangeWrapper, HasAttrs, HasContainer,

View file

@ -28,7 +28,7 @@ use std::{
}; };
use base_db::{ use base_db::{
salsa::{self, ParallelDatabase}, ra_salsa::{self, ParallelDatabase},
SourceRootDatabase, SourceRootId, Upcast, SourceRootDatabase, SourceRootId, Upcast,
}; };
use fst::{raw::IndexedValue, Automaton, Streamer}; use fst::{raw::IndexedValue, Automaton, Streamer};
@ -99,7 +99,7 @@ impl Query {
} }
} }
#[salsa::query_group(SymbolsDatabaseStorage)] #[ra_salsa::query_group(SymbolsDatabaseStorage)]
pub trait SymbolsDatabase: HirDatabase + SourceRootDatabase + Upcast<dyn HirDatabase> { pub trait SymbolsDatabase: HirDatabase + SourceRootDatabase + Upcast<dyn HirDatabase> {
/// The symbol index for a given module. These modules should only be in source roots that /// The symbol index for a given module. These modules should only be in source roots that
/// are inside local_roots. /// are inside local_roots.
@ -108,18 +108,18 @@ pub trait SymbolsDatabase: HirDatabase + SourceRootDatabase + Upcast<dyn HirData
/// The symbol index for a given source root within library_roots. /// The symbol index for a given source root within library_roots.
fn library_symbols(&self, source_root_id: SourceRootId) -> Arc<SymbolIndex>; fn library_symbols(&self, source_root_id: SourceRootId) -> Arc<SymbolIndex>;
#[salsa::transparent] #[ra_salsa::transparent]
/// The symbol indices of modules that make up a given crate. /// The symbol indices of modules that make up a given crate.
fn crate_symbols(&self, krate: Crate) -> Box<[Arc<SymbolIndex>]>; fn crate_symbols(&self, krate: Crate) -> Box<[Arc<SymbolIndex>]>;
/// The set of "local" (that is, from the current workspace) roots. /// The set of "local" (that is, from the current workspace) roots.
/// Files in local roots are assumed to change frequently. /// Files in local roots are assumed to change frequently.
#[salsa::input] #[ra_salsa::input]
fn local_roots(&self) -> Arc<FxHashSet<SourceRootId>>; fn local_roots(&self) -> Arc<FxHashSet<SourceRootId>>;
/// The set of roots for crates.io libraries. /// The set of roots for crates.io libraries.
/// Files in libraries are assumed to never change. /// Files in libraries are assumed to never change.
#[salsa::input] #[ra_salsa::input]
fn library_roots(&self) -> Arc<FxHashSet<SourceRootId>>; fn library_roots(&self) -> Arc<FxHashSet<SourceRootId>>;
} }
@ -155,13 +155,13 @@ pub fn crate_symbols(db: &dyn SymbolsDatabase, krate: Crate) -> Box<[Arc<SymbolI
/// Need to wrap Snapshot to provide `Clone` impl for `map_with` /// Need to wrap Snapshot to provide `Clone` impl for `map_with`
struct Snap<DB>(DB); struct Snap<DB>(DB);
impl<DB: ParallelDatabase> Snap<salsa::Snapshot<DB>> { impl<DB: ParallelDatabase> Snap<ra_salsa::Snapshot<DB>> {
fn new(db: &DB) -> Self { fn new(db: &DB) -> Self {
Self(db.snapshot()) Self(db.snapshot())
} }
} }
impl<DB: ParallelDatabase> Clone for Snap<salsa::Snapshot<DB>> { impl<DB: ParallelDatabase> Clone for Snap<ra_salsa::Snapshot<DB>> {
fn clone(&self) -> Snap<salsa::Snapshot<DB>> { fn clone(&self) -> Snap<ra_salsa::Snapshot<DB>> {
Snap(self.0.snapshot()) Snap(self.0.snapshot())
} }
} }

View file

@ -1,7 +1,7 @@
use expect_test::{expect, Expect}; use expect_test::{expect, Expect};
use hir::{FilePosition, FileRange}; use hir::{FilePosition, FileRange};
use ide_db::{ use ide_db::{
base_db::{salsa::Durability, SourceDatabase}, base_db::{ra_salsa::Durability, SourceDatabase},
EditionedFileId, FxHashSet, EditionedFileId, FxHashSet,
}; };
use test_utils::RangeOrOffset; use test_utils::RangeOrOffset;

View file

@ -64,7 +64,7 @@ use fetch_crates::CrateInfo;
use hir::{sym, ChangeWithProcMacros}; use hir::{sym, ChangeWithProcMacros};
use ide_db::{ use ide_db::{
base_db::{ base_db::{
salsa::{self, ParallelDatabase}, ra_salsa::{self, ParallelDatabase},
CrateOrigin, CrateWorkspaceData, Env, FileLoader, FileSet, SourceDatabase, CrateOrigin, CrateWorkspaceData, Env, FileLoader, FileSet, SourceDatabase,
SourceRootDatabase, VfsPath, SourceRootDatabase, VfsPath,
}, },
@ -218,7 +218,7 @@ impl Default for AnalysisHost {
/// `Analysis` are canceled (most method return `Err(Canceled)`). /// `Analysis` are canceled (most method return `Err(Canceled)`).
#[derive(Debug)] #[derive(Debug)]
pub struct Analysis { pub struct Analysis {
db: salsa::Snapshot<RootDatabase>, db: ra_salsa::Snapshot<RootDatabase>,
} }
// As a general design guideline, `Analysis` API are intended to be independent // As a general design guideline, `Analysis` API are intended to be independent

View file

@ -59,7 +59,7 @@ mod tests {
use expect_test::expect; use expect_test::expect;
use ide_assists::{Assist, AssistResolveStrategy}; use ide_assists::{Assist, AssistResolveStrategy};
use ide_db::{ use ide_db::{
base_db::salsa::Durability, symbol_index::SymbolsDatabase, FileRange, FxHashSet, base_db::ra_salsa::Durability, symbol_index::SymbolsDatabase, FileRange, FxHashSet,
RootDatabase, RootDatabase,
}; };
use test_fixture::WithFixture; use test_fixture::WithFixture;

View file

@ -6,7 +6,7 @@ use hir::{
}; };
use ide_db::{ use ide_db::{
base_db::{ base_db::{
salsa::{ ra_salsa::{
debug::{DebugQueryTable, TableEntry}, debug::{DebugQueryTable, TableEntry},
Query, QueryTable, Query, QueryTable,
}, },

View file

@ -10,7 +10,7 @@ description = "A generic framework for on-demand, incrementalized computation (e
rust-version.workspace = true rust-version.workspace = true
[lib] [lib]
name = "salsa" name = "ra_salsa"
[dependencies] [dependencies]
indexmap = "2.1.0" indexmap = "2.1.0"
@ -23,7 +23,7 @@ oorandom = "11"
triomphe = "0.1.11" triomphe = "0.1.11"
itertools.workspace = true itertools.workspace = true
salsa-macros = { version = "0.0.0", path = "salsa-macros" } ra-salsa-macros = { version = "0.0.0", path = "ra-salsa-macros", package = "salsa-macros" }
[dev-dependencies] [dev-dependencies]
linked-hash-map = "0.5.6" linked-hash-map = "0.5.6"

View file

@ -11,7 +11,7 @@ rust-version.workspace = true
[lib] [lib]
proc-macro = true proc-macro = true
name = "salsa_macros" name = "ra_salsa_macros"
[dependencies] [dependencies]
heck = "0.4" heck = "0.4"

View file

@ -1,4 +1,4 @@
//! Implementation for `[salsa::database]` decorator. //! Implementation for `[ra_salsa::database]` decorator.
use heck::ToSnakeCase; use heck::ToSnakeCase;
use proc_macro::TokenStream; use proc_macro::TokenStream;
@ -32,7 +32,7 @@ pub(crate) fn database(args: TokenStream, input: TokenStream) -> TokenStream {
.iter() .iter()
.map(|QueryGroup { group_path }| { .map(|QueryGroup { group_path }| {
quote! { quote! {
<#group_path as salsa::plumbing::QueryGroup>::GroupStorage <#group_path as ra_salsa::plumbing::QueryGroup>::GroupStorage
} }
}) })
.collect(); .collect();
@ -64,12 +64,12 @@ pub(crate) fn database(args: TokenStream, input: TokenStream) -> TokenStream {
// ANCHOR:HasQueryGroup // ANCHOR:HasQueryGroup
has_group_impls.extend(quote! { has_group_impls.extend(quote! {
impl salsa::plumbing::HasQueryGroup<#group_path> for #database_name { impl ra_salsa::plumbing::HasQueryGroup<#group_path> for #database_name {
fn group_storage(&self) -> &#group_storage { fn group_storage(&self) -> &#group_storage {
&self.#db_storage_field.query_store().#group_name_snake &self.#db_storage_field.query_store().#group_name_snake
} }
fn group_storage_mut(&mut self) -> (&#group_storage, &mut salsa::Runtime) { fn group_storage_mut(&mut self) -> (&#group_storage, &mut ra_salsa::Runtime) {
let (query_store_mut, runtime) = self.#db_storage_field.query_store_mut(); let (query_store_mut, runtime) = self.#db_storage_field.query_store_mut();
(&query_store_mut.#group_name_snake, runtime) (&query_store_mut.#group_name_snake, runtime)
} }
@ -98,13 +98,13 @@ pub(crate) fn database(args: TokenStream, input: TokenStream) -> TokenStream {
let mut database_data = vec![]; let mut database_data = vec![];
for QueryGroup { group_path } in query_groups { for QueryGroup { group_path } in query_groups {
database_data.push(quote! { database_data.push(quote! {
<#group_path as salsa::plumbing::QueryGroup>::GroupData <#group_path as ra_salsa::plumbing::QueryGroup>::GroupData
}); });
} }
// ANCHOR:DatabaseStorageTypes // ANCHOR:DatabaseStorageTypes
output.extend(quote! { output.extend(quote! {
impl salsa::plumbing::DatabaseStorageTypes for #database_name { impl ra_salsa::plumbing::DatabaseStorageTypes for #database_name {
type DatabaseStorage = __SalsaDatabaseStorage; type DatabaseStorage = __SalsaDatabaseStorage;
} }
}); });
@ -121,81 +121,81 @@ pub(crate) fn database(args: TokenStream, input: TokenStream) -> TokenStream {
fmt_ops.extend(quote! { fmt_ops.extend(quote! {
#group_index => { #group_index => {
let storage: &#group_storage = let storage: &#group_storage =
<Self as salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self); <Self as ra_salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self);
storage.fmt_index(self, input, fmt) storage.fmt_index(self, input, fmt)
} }
}); });
maybe_changed_ops.extend(quote! { maybe_changed_ops.extend(quote! {
#group_index => { #group_index => {
let storage: &#group_storage = let storage: &#group_storage =
<Self as salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self); <Self as ra_salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self);
storage.maybe_changed_after(self, input, revision) storage.maybe_changed_after(self, input, revision)
} }
}); });
cycle_recovery_strategy_ops.extend(quote! { cycle_recovery_strategy_ops.extend(quote! {
#group_index => { #group_index => {
let storage: &#group_storage = let storage: &#group_storage =
<Self as salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self); <Self as ra_salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self);
storage.cycle_recovery_strategy(self, input) storage.cycle_recovery_strategy(self, input)
} }
}); });
for_each_ops.extend(quote! { for_each_ops.extend(quote! {
let storage: &#group_storage = let storage: &#group_storage =
<Self as salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self); <Self as ra_salsa::plumbing::HasQueryGroup<#group_path>>::group_storage(self);
storage.for_each_query(runtime, &mut op); storage.for_each_query(runtime, &mut op);
}); });
} }
output.extend(quote! { output.extend(quote! {
impl salsa::plumbing::DatabaseOps for #database_name { impl ra_salsa::plumbing::DatabaseOps for #database_name {
fn ops_database(&self) -> &dyn salsa::Database { fn ops_database(&self) -> &dyn ra_salsa::Database {
self self
} }
fn ops_salsa_runtime(&self) -> &salsa::Runtime { fn ops_salsa_runtime(&self) -> &ra_salsa::Runtime {
self.#db_storage_field.salsa_runtime() self.#db_storage_field.salsa_runtime()
} }
fn synthetic_write(&mut self, durability: salsa::Durability) { fn synthetic_write(&mut self, durability: ra_salsa::Durability) {
self.#db_storage_field.salsa_runtime_mut().synthetic_write(durability) self.#db_storage_field.salsa_runtime_mut().synthetic_write(durability)
} }
fn fmt_index( fn fmt_index(
&self, &self,
input: salsa::DatabaseKeyIndex, input: ra_salsa::DatabaseKeyIndex,
fmt: &mut std::fmt::Formatter<'_>, fmt: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result { ) -> std::fmt::Result {
match input.group_index() { match input.group_index() {
#fmt_ops #fmt_ops
i => panic!("salsa: invalid group index {}", i) i => panic!("ra_salsa: invalid group index {}", i)
} }
} }
fn maybe_changed_after( fn maybe_changed_after(
&self, &self,
input: salsa::DatabaseKeyIndex, input: ra_salsa::DatabaseKeyIndex,
revision: salsa::Revision revision: ra_salsa::Revision
) -> bool { ) -> bool {
match input.group_index() { match input.group_index() {
#maybe_changed_ops #maybe_changed_ops
i => panic!("salsa: invalid group index {}", i) i => panic!("ra_salsa: invalid group index {}", i)
} }
} }
fn cycle_recovery_strategy( fn cycle_recovery_strategy(
&self, &self,
input: salsa::DatabaseKeyIndex, input: ra_salsa::DatabaseKeyIndex,
) -> salsa::plumbing::CycleRecoveryStrategy { ) -> ra_salsa::plumbing::CycleRecoveryStrategy {
match input.group_index() { match input.group_index() {
#cycle_recovery_strategy_ops #cycle_recovery_strategy_ops
i => panic!("salsa: invalid group index {}", i) i => panic!("ra_salsa: invalid group index {}", i)
} }
} }
fn for_each_query( fn for_each_query(
&self, &self,
mut op: &mut dyn FnMut(&dyn salsa::plumbing::QueryStorageMassOps), mut op: &mut dyn FnMut(&dyn ra_salsa::plumbing::QueryStorageMassOps),
) { ) {
let runtime = salsa::Database::salsa_runtime(self); let runtime = ra_salsa::Database::salsa_runtime(self);
#for_each_ops #for_each_ops
} }
} }

View file

@ -1,4 +1,4 @@
//! Implementation for `[salsa::query_group]` decorator. //! Implementation for `[ra_salsa::query_group]` decorator.
use crate::parenthesized::Parenthesized; use crate::parenthesized::Parenthesized;
use heck::ToUpperCamelCase; use heck::ToUpperCamelCase;
@ -10,7 +10,7 @@ use syn::{
ReturnType, TraitItem, Type, ReturnType, TraitItem, Type,
}; };
/// Implementation for `[salsa::query_group]` decorator. /// Implementation for `[ra_salsa::query_group]` decorator.
pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream { pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream {
let group_struct = parse_macro_input!(args as Ident); let group_struct = parse_macro_input!(args as Ident);
let input: ItemTrait = parse_macro_input!(input as ItemTrait); let input: ItemTrait = parse_macro_input!(input as ItemTrait);
@ -82,7 +82,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
num_storages += 1; num_storages += 1;
} }
_ => { _ => {
return Error::new(span, format!("unknown salsa attribute `{name}`")) return Error::new(span, format!("unknown ra_salsa attribute `{name}`"))
.to_compile_error() .to_compile_error()
.into(); .into();
} }
@ -100,7 +100,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
Some(invoke) if storage == QueryStorage::Input => { Some(invoke) if storage == QueryStorage::Input => {
return Error::new( return Error::new(
invoke.span(), invoke.span(),
"#[salsa::invoke] cannot be set on #[salsa::input] queries", "#[ra_salsa::invoke] cannot be set on #[ra_salsa::input] queries",
) )
.to_compile_error() .to_compile_error()
.into(); .into();
@ -155,7 +155,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
} }
}; };
// For `#[salsa::interned]` keys, we create a "lookup key" automatically. // For `#[ra_salsa::interned]` keys, we create a "lookup key" automatically.
// //
// For a query like: // For a query like:
// //
@ -257,7 +257,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
// difference in total compilation time in rust-analyzer, though // difference in total compilation time in rust-analyzer, though
// it's not totally obvious why that should be. // it's not totally obvious why that should be.
fn __shim(db: &(dyn #trait_name + '_), #(#key_names: #keys),*) -> #value { fn __shim(db: &(dyn #trait_name + '_), #(#key_names: #keys),*) -> #value {
salsa::plumbing::get_query_table::<#qt>(db).get((#(#key_names),*)) ra_salsa::plumbing::get_query_table::<#qt>(db).get((#(#key_names),*))
} }
__shim(self, #(#key_names),*) __shim(self, #(#key_names),*)
@ -302,20 +302,20 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
# [doc = #set_constant_fn_docs] # [doc = #set_constant_fn_docs]
fn #set_with_durability_fn_name(&mut self, #(#key_names: #keys,)* value__: #value, durability__: salsa::Durability); fn #set_with_durability_fn_name(&mut self, #(#key_names: #keys,)* value__: #value, durability__: ra_salsa::Durability);
}); });
query_fn_definitions.extend(quote! { query_fn_definitions.extend(quote! {
fn #set_fn_name(&mut self, #(#key_names: #keys,)* value__: #value) { fn #set_fn_name(&mut self, #(#key_names: #keys,)* value__: #value) {
fn __shim(db: &mut dyn #trait_name, #(#key_names: #keys,)* value__: #value) { fn __shim(db: &mut dyn #trait_name, #(#key_names: #keys,)* value__: #value) {
salsa::plumbing::get_query_table_mut::<#qt>(db).set((#(#key_names),*), value__) ra_salsa::plumbing::get_query_table_mut::<#qt>(db).set((#(#key_names),*), value__)
} }
__shim(self, #(#key_names,)* value__) __shim(self, #(#key_names,)* value__)
} }
fn #set_with_durability_fn_name(&mut self, #(#key_names: #keys,)* value__: #value, durability__: salsa::Durability) { fn #set_with_durability_fn_name(&mut self, #(#key_names: #keys,)* value__: #value, durability__: ra_salsa::Durability) {
fn __shim(db: &mut dyn #trait_name, #(#key_names: #keys,)* value__: #value, durability__: salsa::Durability) { fn __shim(db: &mut dyn #trait_name, #(#key_names: #keys,)* value__: #value, durability__: ra_salsa::Durability) {
salsa::plumbing::get_query_table_mut::<#qt>(db).set_with_durability((#(#key_names),*), value__, durability__) ra_salsa::plumbing::get_query_table_mut::<#qt>(db).set_with_durability((#(#key_names),*), value__, durability__)
} }
__shim(self, #(#key_names,)* value__ ,durability__) __shim(self, #(#key_names,)* value__ ,durability__)
} }
@ -324,7 +324,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
// A field for the storage struct // A field for the storage struct
storage_fields.extend(quote! { storage_fields.extend(quote! {
#fn_name: std::sync::Arc<<#qt as salsa::Query>::Storage>, #fn_name: std::sync::Arc<<#qt as ra_salsa::Query>::Storage>,
}); });
} }
@ -334,8 +334,8 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
quote! { quote! {
#(#trait_attrs)* #(#trait_attrs)*
#trait_vis trait #trait_name : #trait_vis trait #trait_name :
salsa::Database + ra_salsa::Database +
salsa::plumbing::HasQueryGroup<#group_struct> + ra_salsa::plumbing::HasQueryGroup<#group_struct> +
#bounds #bounds
{ {
#query_fn_declarations #query_fn_declarations
@ -348,7 +348,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
/// Representative struct for the query group. /// Representative struct for the query group.
#trait_vis struct #group_struct { } #trait_vis struct #group_struct { }
impl salsa::plumbing::QueryGroup for #group_struct impl ra_salsa::plumbing::QueryGroup for #group_struct
{ {
type DynDb = #dyn_db; type DynDb = #dyn_db;
type GroupStorage = #group_storage; type GroupStorage = #group_storage;
@ -362,8 +362,8 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
impl<DB> #trait_name for DB impl<DB> #trait_name for DB
where where
DB: #bounds, DB: #bounds,
DB: salsa::Database, DB: ra_salsa::Database,
DB: salsa::plumbing::HasQueryGroup<#group_struct>, DB: ra_salsa::plumbing::HasQueryGroup<#group_struct>,
{ {
#query_fn_definitions #query_fn_definitions
} }
@ -379,18 +379,18 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
let qt = &query.query_type; let qt = &query.query_type;
let storage = match &query.storage { let storage = match &query.storage {
QueryStorage::Memoized => quote!(salsa::plumbing::MemoizedStorage<Self>), QueryStorage::Memoized => quote!(ra_salsa::plumbing::MemoizedStorage<Self>),
QueryStorage::LruMemoized => quote!(salsa::plumbing::LruMemoizedStorage<Self>), QueryStorage::LruMemoized => quote!(ra_salsa::plumbing::LruMemoizedStorage<Self>),
QueryStorage::LruDependencies => { QueryStorage::LruDependencies => {
quote!(salsa::plumbing::LruDependencyStorage<Self>) quote!(ra_salsa::plumbing::LruDependencyStorage<Self>)
} }
QueryStorage::Input if query.keys.is_empty() => { QueryStorage::Input if query.keys.is_empty() => {
quote!(salsa::plumbing::UnitInputStorage<Self>) quote!(ra_salsa::plumbing::UnitInputStorage<Self>)
} }
QueryStorage::Input => quote!(salsa::plumbing::InputStorage<Self>), QueryStorage::Input => quote!(ra_salsa::plumbing::InputStorage<Self>),
QueryStorage::Interned => quote!(salsa::plumbing::InternedStorage<Self>), QueryStorage::Interned => quote!(ra_salsa::plumbing::InternedStorage<Self>),
QueryStorage::InternedLookup { intern_query_type } => { QueryStorage::InternedLookup { intern_query_type } => {
quote!(salsa::plumbing::LookupInternedStorage<Self, #intern_query_type>) quote!(ra_salsa::plumbing::LookupInternedStorage<Self, #intern_query_type>)
} }
QueryStorage::Transparent => panic!("should have been filtered"), QueryStorage::Transparent => panic!("should have been filtered"),
}; };
@ -408,9 +408,9 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
impl #qt { impl #qt {
/// Get access to extra methods pertaining to this query. /// Get access to extra methods pertaining to this query.
/// You can also use it to invoke this query. /// You can also use it to invoke this query.
#trait_vis fn in_db(self, db: &#dyn_db) -> salsa::QueryTable<'_, Self> #trait_vis fn in_db(self, db: &#dyn_db) -> ra_salsa::QueryTable<'_, Self>
{ {
salsa::plumbing::get_query_table::<#qt>(db) ra_salsa::plumbing::get_query_table::<#qt>(db)
} }
} }
}); });
@ -439,7 +439,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
/// also set a cancellation flag. This will cause any query /// also set a cancellation flag. This will cause any query
/// invocations in other threads to unwind with a `Cancelled` /// invocations in other threads to unwind with a `Cancelled`
/// sentinel value and eventually let the `set` succeed once all /// sentinel value and eventually let the `set` succeed once all
/// threads have unwound past the salsa invocation. /// threads have unwound past the ra_salsa invocation.
/// ///
/// If your query implementations are performing expensive /// If your query implementations are performing expensive
/// operations without invoking another query, you can also use /// operations without invoking another query, you can also use
@ -448,13 +448,13 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
/// thus allowing the `set` to succeed. Otherwise, long-running /// thus allowing the `set` to succeed. Otherwise, long-running
/// computations may lead to "starvation", meaning that the /// computations may lead to "starvation", meaning that the
/// thread attempting to `set` has to wait a long, long time. =) /// thread attempting to `set` has to wait a long, long time. =)
#trait_vis fn in_db_mut(self, db: &mut #dyn_db) -> salsa::QueryTableMut<'_, Self> #trait_vis fn in_db_mut(self, db: &mut #dyn_db) -> ra_salsa::QueryTableMut<'_, Self>
{ {
salsa::plumbing::get_query_table_mut::<#qt>(db) ra_salsa::plumbing::get_query_table_mut::<#qt>(db)
} }
} }
impl<'d> salsa::QueryDb<'d> for #qt impl<'d> ra_salsa::QueryDb<'d> for #qt
{ {
type DynDb = #dyn_db + 'd; type DynDb = #dyn_db + 'd;
type Group = #group_struct; type Group = #group_struct;
@ -462,7 +462,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
} }
// ANCHOR:Query_impl // ANCHOR:Query_impl
impl salsa::Query for #qt impl ra_salsa::Query for #qt
{ {
type Key = (#(#keys),*); type Key = (#(#keys),*);
type Value = #value; type Value = #value;
@ -473,13 +473,13 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
const QUERY_NAME: &'static str = #query_name; const QUERY_NAME: &'static str = #query_name;
fn query_storage<'a>( fn query_storage<'a>(
group_storage: &'a <Self as salsa::QueryDb<'_>>::GroupStorage, group_storage: &'a <Self as ra_salsa::QueryDb<'_>>::GroupStorage,
) -> &'a std::sync::Arc<Self::Storage> { ) -> &'a std::sync::Arc<Self::Storage> {
&group_storage.#fn_name &group_storage.#fn_name
} }
fn query_storage_mut<'a>( fn query_storage_mut<'a>(
group_storage: &'a <Self as salsa::QueryDb<'_>>::GroupStorage, group_storage: &'a <Self as ra_salsa::QueryDb<'_>>::GroupStorage,
) -> &'a std::sync::Arc<Self::Storage> { ) -> &'a std::sync::Arc<Self::Storage> {
&group_storage.#fn_name &group_storage.#fn_name
} }
@ -501,10 +501,10 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
let recover = if let Some(cycle_recovery_fn) = &query.cycle { let recover = if let Some(cycle_recovery_fn) = &query.cycle {
quote! { quote! {
const CYCLE_STRATEGY: salsa::plumbing::CycleRecoveryStrategy = const CYCLE_STRATEGY: ra_salsa::plumbing::CycleRecoveryStrategy =
salsa::plumbing::CycleRecoveryStrategy::Fallback; ra_salsa::plumbing::CycleRecoveryStrategy::Fallback;
fn cycle_fallback(db: &<Self as salsa::QueryDb<'_>>::DynDb, cycle: &salsa::Cycle, #key_pattern: &<Self as salsa::Query>::Key) fn cycle_fallback(db: &<Self as ra_salsa::QueryDb<'_>>::DynDb, cycle: &ra_salsa::Cycle, #key_pattern: &<Self as ra_salsa::Query>::Key)
-> <Self as salsa::Query>::Value { -> <Self as ra_salsa::Query>::Value {
#cycle_recovery_fn( #cycle_recovery_fn(
db, db,
cycle, cycle,
@ -514,17 +514,17 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
} }
} else { } else {
quote! { quote! {
const CYCLE_STRATEGY: salsa::plumbing::CycleRecoveryStrategy = const CYCLE_STRATEGY: ra_salsa::plumbing::CycleRecoveryStrategy =
salsa::plumbing::CycleRecoveryStrategy::Panic; ra_salsa::plumbing::CycleRecoveryStrategy::Panic;
} }
}; };
output.extend(quote_spanned! {span=> output.extend(quote_spanned! {span=>
// ANCHOR:QueryFunction_impl // ANCHOR:QueryFunction_impl
impl salsa::plumbing::QueryFunction for #qt impl ra_salsa::plumbing::QueryFunction for #qt
{ {
fn execute(db: &<Self as salsa::QueryDb<'_>>::DynDb, #key_pattern: <Self as salsa::Query>::Key) fn execute(db: &<Self as ra_salsa::QueryDb<'_>>::DynDb, #key_pattern: <Self as ra_salsa::Query>::Key)
-> <Self as salsa::Query>::Value { -> <Self as ra_salsa::Query>::Value {
#invoke(db, #(#key_names),*) #invoke(db, #(#key_names),*)
} }
@ -539,7 +539,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
for (Query { fn_name, .. }, query_index) in non_transparent_queries().zip(0_u16..) { for (Query { fn_name, .. }, query_index) in non_transparent_queries().zip(0_u16..) {
fmt_ops.extend(quote! { fmt_ops.extend(quote! {
#query_index => { #query_index => {
salsa::plumbing::QueryStorageOps::fmt_index( ra_salsa::plumbing::QueryStorageOps::fmt_index(
&*self.#fn_name, db, input.key_index(), fmt, &*self.#fn_name, db, input.key_index(), fmt,
) )
} }
@ -550,7 +550,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
for (Query { fn_name, .. }, query_index) in non_transparent_queries().zip(0_u16..) { for (Query { fn_name, .. }, query_index) in non_transparent_queries().zip(0_u16..) {
maybe_changed_ops.extend(quote! { maybe_changed_ops.extend(quote! {
#query_index => { #query_index => {
salsa::plumbing::QueryStorageOps::maybe_changed_after( ra_salsa::plumbing::QueryStorageOps::maybe_changed_after(
&*self.#fn_name, db, input.key_index(), revision &*self.#fn_name, db, input.key_index(), revision
) )
} }
@ -561,7 +561,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
for (Query { fn_name, .. }, query_index) in non_transparent_queries().zip(0_u16..) { for (Query { fn_name, .. }, query_index) in non_transparent_queries().zip(0_u16..) {
cycle_recovery_strategy_ops.extend(quote! { cycle_recovery_strategy_ops.extend(quote! {
#query_index => { #query_index => {
salsa::plumbing::QueryStorageOps::cycle_recovery_strategy( ra_salsa::plumbing::QueryStorageOps::cycle_recovery_strategy(
&*self.#fn_name &*self.#fn_name
) )
} }
@ -587,7 +587,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
#group_storage { #group_storage {
#( #(
#queries_with_storage: #queries_with_storage:
std::sync::Arc::new(salsa::plumbing::QueryStorageOps::new(group_index)), std::sync::Arc::new(ra_salsa::plumbing::QueryStorageOps::new(group_index)),
)* )*
} }
} }
@ -599,42 +599,42 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
#trait_vis fn fmt_index( #trait_vis fn fmt_index(
&self, &self,
db: &(#dyn_db + '_), db: &(#dyn_db + '_),
input: salsa::DatabaseKeyIndex, input: ra_salsa::DatabaseKeyIndex,
fmt: &mut std::fmt::Formatter<'_>, fmt: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result { ) -> std::fmt::Result {
match input.query_index() { match input.query_index() {
#fmt_ops #fmt_ops
i => panic!("salsa: impossible query index {}", i), i => panic!("ra_salsa: impossible query index {}", i),
} }
} }
#trait_vis fn maybe_changed_after( #trait_vis fn maybe_changed_after(
&self, &self,
db: &(#dyn_db + '_), db: &(#dyn_db + '_),
input: salsa::DatabaseKeyIndex, input: ra_salsa::DatabaseKeyIndex,
revision: salsa::Revision, revision: ra_salsa::Revision,
) -> bool { ) -> bool {
match input.query_index() { match input.query_index() {
#maybe_changed_ops #maybe_changed_ops
i => panic!("salsa: impossible query index {}", i), i => panic!("ra_salsa: impossible query index {}", i),
} }
} }
#trait_vis fn cycle_recovery_strategy( #trait_vis fn cycle_recovery_strategy(
&self, &self,
db: &(#dyn_db + '_), db: &(#dyn_db + '_),
input: salsa::DatabaseKeyIndex, input: ra_salsa::DatabaseKeyIndex,
) -> salsa::plumbing::CycleRecoveryStrategy { ) -> ra_salsa::plumbing::CycleRecoveryStrategy {
match input.query_index() { match input.query_index() {
#cycle_recovery_strategy_ops #cycle_recovery_strategy_ops
i => panic!("salsa: impossible query index {}", i), i => panic!("ra_salsa: impossible query index {}", i),
} }
} }
#trait_vis fn for_each_query( #trait_vis fn for_each_query(
&self, &self,
_runtime: &salsa::Runtime, _runtime: &ra_salsa::Runtime,
mut op: &mut dyn FnMut(&dyn salsa::plumbing::QueryStorageMassOps), mut op: &mut dyn FnMut(&dyn ra_salsa::plumbing::QueryStorageMassOps),
) { ) {
#for_each_ops #for_each_ops
} }
@ -684,23 +684,23 @@ impl TryFrom<syn::Attribute> for SalsaAttr {
} }
fn is_not_salsa_attr_path(path: &syn::Path) -> bool { fn is_not_salsa_attr_path(path: &syn::Path) -> bool {
path.segments.first().map(|s| s.ident != "salsa").unwrap_or(true) || path.segments.len() != 2 path.segments.first().map(|s| s.ident != "ra_salsa").unwrap_or(true) || path.segments.len() != 2
} }
fn filter_attrs(attrs: Vec<Attribute>) -> (Vec<Attribute>, Vec<SalsaAttr>) { fn filter_attrs(attrs: Vec<Attribute>) -> (Vec<Attribute>, Vec<SalsaAttr>) {
let mut other = vec![]; let mut other = vec![];
let mut salsa = vec![]; let mut ra_salsa = vec![];
// Leave non-salsa attributes untouched. These are // Leave non-ra_salsa attributes untouched. These are
// attributes that don't start with `salsa::` or don't have // attributes that don't start with `ra_salsa::` or don't have
// exactly two segments in their path. // exactly two segments in their path.
// Keep the salsa attributes around. // Keep the ra_salsa attributes around.
for attr in attrs { for attr in attrs {
match SalsaAttr::try_from(attr) { match SalsaAttr::try_from(attr) {
Ok(it) => salsa.push(it), Ok(it) => ra_salsa.push(it),
Err(it) => other.push(it), Err(it) => other.push(it),
} }
} }
(other, salsa) (other, ra_salsa)
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -12,7 +12,7 @@ use std::num::NonZeroU32;
/// which are implemented for `u32` and `usize`: /// which are implemented for `u32` and `usize`:
/// ///
/// ``` /// ```
/// # use salsa::InternId; /// # use ra_salsa::InternId;
/// let intern_id1 = InternId::from(22_u32); /// let intern_id1 = InternId::from(22_u32);
/// let intern_id2 = InternId::from(22_usize); /// let intern_id2 = InternId::from(22_usize);
/// assert_eq!(intern_id1, intern_id2); /// assert_eq!(intern_id1, intern_id2);
@ -25,7 +25,7 @@ use std::num::NonZeroU32;
/// `usize` using the `as_u32` or `as_usize` methods or the `From` impls. /// `usize` using the `as_u32` or `as_usize` methods or the `From` impls.
/// ///
/// ``` /// ```
/// # use salsa::InternId; /// # use ra_salsa::InternId;;
/// let intern_id = InternId::from(22_u32); /// let intern_id = InternId::from(22_u32);
/// let value = u32::from(intern_id); /// let value = u32::from(intern_id);
/// assert_eq!(value, 22); /// assert_eq!(value, 22);
@ -41,7 +41,7 @@ use std::num::NonZeroU32;
/// word. /// word.
/// ///
/// ```should_panic /// ```should_panic
/// # use salsa::InternId; /// # use ra_salsa::InternId;;
/// InternId::from(InternId::MAX); /// InternId::from(InternId::MAX);
/// ``` /// ```
/// ///
@ -70,7 +70,7 @@ impl InternId {
/// Convert this raw-id into a u32 value. /// Convert this raw-id into a u32 value.
/// ///
/// ``` /// ```
/// # use salsa::InternId; /// # use ra_salsa::InternId;
/// let intern_id = InternId::from(22_u32); /// let intern_id = InternId::from(22_u32);
/// let value = intern_id.as_usize(); /// let value = intern_id.as_usize();
/// assert_eq!(value, 22); /// assert_eq!(value, 22);
@ -82,7 +82,7 @@ impl InternId {
/// Convert this raw-id into a usize value. /// Convert this raw-id into a usize value.
/// ///
/// ``` /// ```
/// # use salsa::InternId; /// # use ra_salsa::InternId;
/// let intern_id = InternId::from(22_u32); /// let intern_id = InternId::from(22_u32);
/// let value = intern_id.as_usize(); /// let value = intern_id.as_usize();
/// assert_eq!(value, 22); /// assert_eq!(value, 22);

View file

@ -745,6 +745,6 @@ impl Cycle {
// Re-export the procedural macros. // Re-export the procedural macros.
#[allow(unused_imports)] #[allow(unused_imports)]
#[macro_use] #[macro_use]
extern crate salsa_macros; extern crate ra_salsa_macros;
use plumbing::HasQueryGroup; use plumbing::HasQueryGroup;
pub use salsa_macros::*; pub use ra_salsa_macros::*;

View file

@ -1,7 +1,7 @@
use std::panic::UnwindSafe; use std::panic::UnwindSafe;
use expect_test::expect; use expect_test::expect;
use salsa::{Durability, ParallelDatabase, Snapshot}; use ra_salsa::{Durability, ParallelDatabase, Snapshot};
// Axes: // Axes:
// //
@ -49,13 +49,13 @@ struct Error {
cycle: Vec<String>, cycle: Vec<String>,
} }
#[salsa::database(GroupStruct)] #[ra_salsa::database(GroupStruct)]
#[derive(Default)] #[derive(Default)]
struct DatabaseImpl { struct DatabaseImpl {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for DatabaseImpl {} impl ra_salsa::Database for DatabaseImpl {}
impl ParallelDatabase for DatabaseImpl { impl ParallelDatabase for DatabaseImpl {
fn snapshot(&self) -> Snapshot<Self> { fn snapshot(&self) -> Snapshot<Self> {
@ -75,37 +75,37 @@ enum CycleQuery {
AthenC, AthenC,
} }
#[salsa::query_group(GroupStruct)] #[ra_salsa::query_group(GroupStruct)]
trait Database: salsa::Database { trait Database: ra_salsa::Database {
// `a` and `b` depend on each other and form a cycle // `a` and `b` depend on each other and form a cycle
fn memoized_a(&self) -> (); fn memoized_a(&self) -> ();
fn memoized_b(&self) -> (); fn memoized_b(&self) -> ();
fn volatile_a(&self) -> (); fn volatile_a(&self) -> ();
fn volatile_b(&self) -> (); fn volatile_b(&self) -> ();
#[salsa::input] #[ra_salsa::input]
fn a_invokes(&self) -> CycleQuery; fn a_invokes(&self) -> CycleQuery;
#[salsa::input] #[ra_salsa::input]
fn b_invokes(&self) -> CycleQuery; fn b_invokes(&self) -> CycleQuery;
#[salsa::input] #[ra_salsa::input]
fn c_invokes(&self) -> CycleQuery; fn c_invokes(&self) -> CycleQuery;
#[salsa::cycle(recover_a)] #[ra_salsa::cycle(recover_a)]
fn cycle_a(&self) -> Result<(), Error>; fn cycle_a(&self) -> Result<(), Error>;
#[salsa::cycle(recover_b)] #[ra_salsa::cycle(recover_b)]
fn cycle_b(&self) -> Result<(), Error>; fn cycle_b(&self) -> Result<(), Error>;
fn cycle_c(&self) -> Result<(), Error>; fn cycle_c(&self) -> Result<(), Error>;
} }
fn recover_a(db: &dyn Database, cycle: &salsa::Cycle) -> Result<(), Error> { fn recover_a(db: &dyn Database, cycle: &ra_salsa::Cycle) -> Result<(), Error> {
Err(Error { cycle: cycle.all_participants(db) }) Err(Error { cycle: cycle.all_participants(db) })
} }
fn recover_b(db: &dyn Database, cycle: &salsa::Cycle) -> Result<(), Error> { fn recover_b(db: &dyn Database, cycle: &ra_salsa::Cycle) -> Result<(), Error> {
Err(Error { cycle: cycle.all_participants(db) }) Err(Error { cycle: cycle.all_participants(db) })
} }
@ -155,10 +155,10 @@ fn cycle_c(db: &dyn Database) -> Result<(), Error> {
} }
#[track_caller] #[track_caller]
fn extract_cycle(f: impl FnOnce() + UnwindSafe) -> salsa::Cycle { fn extract_cycle(f: impl FnOnce() + UnwindSafe) -> ra_salsa::Cycle {
let v = std::panic::catch_unwind(f); let v = std::panic::catch_unwind(f);
if let Err(d) = &v { if let Err(d) = &v {
if let Some(cycle) = d.downcast_ref::<salsa::Cycle>() { if let Some(cycle) = d.downcast_ref::<ra_salsa::Cycle>() {
return cycle.clone(); return cycle.clone();
} }
} }

View file

@ -1,16 +1,16 @@
//! Test that you can implement a query using a `dyn Trait` setup. //! Test that you can implement a query using a `dyn Trait` setup.
#[salsa::database(DynTraitStorage)] #[ra_salsa::database(DynTraitStorage)]
#[derive(Default)] #[derive(Default)]
struct DynTraitDatabase { struct DynTraitDatabase {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for DynTraitDatabase {} impl ra_salsa::Database for DynTraitDatabase {}
#[salsa::query_group(DynTraitStorage)] #[ra_salsa::query_group(DynTraitStorage)]
trait DynTrait { trait DynTrait {
#[salsa::input] #[ra_salsa::input]
fn input(&self, x: u32) -> u32; fn input(&self, x: u32) -> u32;
fn output(&self, x: u32) -> u32; fn output(&self, x: u32) -> u32;

View file

@ -1,10 +1,10 @@
use crate::implementation::{TestContext, TestContextImpl}; use crate::implementation::{TestContext, TestContextImpl};
use salsa::debug::DebugQueryTable; use ra_salsa::debug::DebugQueryTable;
use salsa::Durability; use ra_salsa::Durability;
#[salsa::query_group(Constants)] #[ra_salsa::query_group(Constants)]
pub(crate) trait ConstantsDatabase: TestContext { pub(crate) trait ConstantsDatabase: TestContext {
#[salsa::input] #[ra_salsa::input]
fn input(&self, key: char) -> usize; fn input(&self, key: char) -> usize;
fn add(&self, key1: char, key2: char) -> usize; fn add(&self, key1: char, key2: char) -> usize;

View file

@ -5,12 +5,12 @@ use crate::memoized_dep_inputs;
use crate::memoized_inputs; use crate::memoized_inputs;
use crate::memoized_volatile; use crate::memoized_volatile;
pub(crate) trait TestContext: salsa::Database { pub(crate) trait TestContext: ra_salsa::Database {
fn clock(&self) -> &Counter; fn clock(&self) -> &Counter;
fn log(&self) -> &Log; fn log(&self) -> &Log;
} }
#[salsa::database( #[ra_salsa::database(
constants::Constants, constants::Constants,
memoized_dep_inputs::MemoizedDepInputs, memoized_dep_inputs::MemoizedDepInputs,
memoized_inputs::MemoizedInputs, memoized_inputs::MemoizedInputs,
@ -18,7 +18,7 @@ pub(crate) trait TestContext: salsa::Database {
)] )]
#[derive(Default)] #[derive(Default)]
pub(crate) struct TestContextImpl { pub(crate) struct TestContextImpl {
storage: salsa::Storage<TestContextImpl>, storage: ra_salsa::Storage<TestContextImpl>,
clock: Counter, clock: Counter,
log: Log, log: Log,
} }
@ -56,4 +56,4 @@ impl TestContext for TestContextImpl {
} }
} }
impl salsa::Database for TestContextImpl {} impl ra_salsa::Database for TestContextImpl {}

View file

@ -1,14 +1,14 @@
use crate::implementation::{TestContext, TestContextImpl}; use crate::implementation::{TestContext, TestContextImpl};
#[salsa::query_group(MemoizedDepInputs)] #[ra_salsa::query_group(MemoizedDepInputs)]
pub(crate) trait MemoizedDepInputsContext: TestContext { pub(crate) trait MemoizedDepInputsContext: TestContext {
fn dep_memoized2(&self) -> usize; fn dep_memoized2(&self) -> usize;
fn dep_memoized1(&self) -> usize; fn dep_memoized1(&self) -> usize;
#[salsa::dependencies] #[ra_salsa::dependencies]
fn dep_derived1(&self) -> usize; fn dep_derived1(&self) -> usize;
#[salsa::input] #[ra_salsa::input]
fn dep_input1(&self) -> usize; fn dep_input1(&self) -> usize;
#[salsa::input] #[ra_salsa::input]
fn dep_input2(&self) -> usize; fn dep_input2(&self) -> usize;
} }

View file

@ -1,11 +1,11 @@
use crate::implementation::{TestContext, TestContextImpl}; use crate::implementation::{TestContext, TestContextImpl};
#[salsa::query_group(MemoizedInputs)] #[ra_salsa::query_group(MemoizedInputs)]
pub(crate) trait MemoizedInputsContext: TestContext { pub(crate) trait MemoizedInputsContext: TestContext {
fn max(&self) -> usize; fn max(&self) -> usize;
#[salsa::input] #[ra_salsa::input]
fn input1(&self) -> usize; fn input1(&self) -> usize;
#[salsa::input] #[ra_salsa::input]
fn input2(&self) -> usize; fn input2(&self) -> usize;
} }

View file

@ -1,7 +1,7 @@
use crate::implementation::{TestContext, TestContextImpl}; use crate::implementation::{TestContext, TestContextImpl};
use salsa::{Database, Durability}; use ra_salsa::{Database, Durability};
#[salsa::query_group(MemoizedVolatile)] #[ra_salsa::query_group(MemoizedVolatile)]
pub(crate) trait MemoizedVolatileContext: TestContext { pub(crate) trait MemoizedVolatileContext: TestContext {
// Queries for testing a "volatile" value wrapped by // Queries for testing a "volatile" value wrapped by
// memoization. // memoization.

View file

@ -1,37 +1,37 @@
//! Test that you can implement a query using a `dyn Trait` setup. //! Test that you can implement a query using a `dyn Trait` setup.
use salsa::InternId; use ra_salsa::InternId;
#[salsa::database(InternStorage)] #[ra_salsa::database(InternStorage)]
#[derive(Default)] #[derive(Default)]
struct Database { struct Database {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for Database {} impl ra_salsa::Database for Database {}
impl salsa::ParallelDatabase for Database { impl ra_salsa::ParallelDatabase for Database {
fn snapshot(&self) -> salsa::Snapshot<Self> { fn snapshot(&self) -> ra_salsa::Snapshot<Self> {
salsa::Snapshot::new(Database { storage: self.storage.snapshot() }) ra_salsa::Snapshot::new(Database { storage: self.storage.snapshot() })
} }
} }
#[salsa::query_group(InternStorage)] #[ra_salsa::query_group(InternStorage)]
trait Intern { trait Intern {
#[salsa::interned] #[ra_salsa::interned]
fn intern1(&self, x: String) -> InternId; fn intern1(&self, x: String) -> InternId;
#[salsa::interned] #[ra_salsa::interned]
fn intern2(&self, x: String, y: String) -> InternId; fn intern2(&self, x: String, y: String) -> InternId;
#[salsa::interned] #[ra_salsa::interned]
fn intern_key(&self, x: String) -> InternKey; fn intern_key(&self, x: String) -> InternKey;
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct InternKey(InternId); pub struct InternKey(InternId);
impl salsa::InternKey for InternKey { impl ra_salsa::InternKey for InternKey {
fn from_intern_id(v: InternId) -> Self { fn from_intern_id(v: InternId) -> Self {
InternKey(v) InternKey(v)
} }

View file

@ -22,11 +22,11 @@ impl Drop for HotPotato {
} }
} }
#[salsa::query_group(QueryGroupStorage)] #[ra_salsa::query_group(QueryGroupStorage)]
trait QueryGroup: salsa::Database { trait QueryGroup: ra_salsa::Database {
#[salsa::lru] #[ra_salsa::lru]
fn get(&self, x: u32) -> Arc<HotPotato>; fn get(&self, x: u32) -> Arc<HotPotato>;
#[salsa::lru] #[ra_salsa::lru]
fn get_volatile(&self, x: u32) -> usize; fn get_volatile(&self, x: u32) -> usize;
} }
@ -40,13 +40,13 @@ fn get_volatile(db: &dyn QueryGroup, _x: u32) -> usize {
COUNTER.fetch_add(1, Ordering::SeqCst) COUNTER.fetch_add(1, Ordering::SeqCst)
} }
#[salsa::database(QueryGroupStorage)] #[ra_salsa::database(QueryGroupStorage)]
#[derive(Default)] #[derive(Default)]
struct Database { struct Database {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for Database {} impl ra_salsa::Database for Database {}
#[test] #[test]
fn lru_works() { fn lru_works() {

View file

@ -1,6 +1,6 @@
#[salsa::query_group(MyStruct)] #[ra_salsa::query_group(MyStruct)]
trait MyDatabase: salsa::Database { trait MyDatabase: ra_salsa::Database {
#[salsa::invoke(another_module::another_name)] #[ra_salsa::invoke(another_module::another_name)]
fn my_query(&self, key: ()) -> (); fn my_query(&self, key: ()) -> ();
} }

View file

@ -1,7 +1,7 @@
use std::rc::Rc; use std::rc::Rc;
#[salsa::query_group(NoSendSyncStorage)] #[ra_salsa::query_group(NoSendSyncStorage)]
trait NoSendSyncDatabase: salsa::Database { trait NoSendSyncDatabase: ra_salsa::Database {
fn no_send_sync_value(&self, key: bool) -> Rc<bool>; fn no_send_sync_value(&self, key: bool) -> Rc<bool>;
fn no_send_sync_key(&self, key: Rc<bool>) -> bool; fn no_send_sync_key(&self, key: Rc<bool>) -> bool;
} }
@ -14,13 +14,13 @@ fn no_send_sync_key(_db: &dyn NoSendSyncDatabase, key: Rc<bool>) -> bool {
*key *key
} }
#[salsa::database(NoSendSyncStorage)] #[ra_salsa::database(NoSendSyncStorage)]
#[derive(Default)] #[derive(Default)]
struct DatabaseImpl { struct DatabaseImpl {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for DatabaseImpl {} impl ra_salsa::Database for DatabaseImpl {}
#[test] #[test]
fn no_send_sync() { fn no_send_sync() {

View file

@ -8,10 +8,10 @@
use std::{cell::RefCell, collections::HashMap, rc::Rc}; use std::{cell::RefCell, collections::HashMap, rc::Rc};
use salsa::{Database as _, Durability, EventKind}; use ra_salsa::{Database as _, Durability, EventKind};
#[salsa::query_group(QueryGroupStorage)] #[ra_salsa::query_group(QueryGroupStorage)]
trait QueryGroup: salsa::Database + AsRef<HashMap<u32, u32>> { trait QueryGroup: ra_salsa::Database + AsRef<HashMap<u32, u32>> {
fn a(&self, x: u32) -> u32; fn a(&self, x: u32) -> u32;
fn b(&self, x: u32) -> u32; fn b(&self, x: u32) -> u32;
fn c(&self, x: u32) -> u32; fn c(&self, x: u32) -> u32;
@ -32,16 +32,16 @@ fn c(db: &dyn QueryGroup, x: u32) -> u32 {
db.b(x) db.b(x)
} }
#[salsa::database(QueryGroupStorage)] #[ra_salsa::database(QueryGroupStorage)]
#[derive(Default)] #[derive(Default)]
struct Database { struct Database {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
external_state: HashMap<u32, u32>, external_state: HashMap<u32, u32>,
on_event: Option<Box<dyn Fn(&Database, salsa::Event)>>, on_event: Option<Box<dyn Fn(&Database, ra_salsa::Event)>>,
} }
impl salsa::Database for Database { impl ra_salsa::Database for Database {
fn salsa_event(&self, event: salsa::Event) { fn salsa_event(&self, event: ra_salsa::Event) {
if let Some(cb) = &self.on_event { if let Some(cb) = &self.on_event {
cb(self, event) cb(self, event)
} }

View file

@ -1,10 +1,10 @@
use salsa::{Database, ParallelDatabase, Snapshot}; use ra_salsa::{Database, ParallelDatabase, Snapshot};
use std::panic::{self, AssertUnwindSafe}; use std::panic::{self, AssertUnwindSafe};
use std::sync::atomic::{AtomicU32, Ordering::SeqCst}; use std::sync::atomic::{AtomicU32, Ordering::SeqCst};
#[salsa::query_group(PanicSafelyStruct)] #[ra_salsa::query_group(PanicSafelyStruct)]
trait PanicSafelyDatabase: salsa::Database { trait PanicSafelyDatabase: ra_salsa::Database {
#[salsa::input] #[ra_salsa::input]
fn one(&self) -> usize; fn one(&self) -> usize;
fn panic_safely(&self) -> (); fn panic_safely(&self) -> ();
@ -23,15 +23,15 @@ fn outer(db: &dyn PanicSafelyDatabase) {
db.panic_safely(); db.panic_safely();
} }
#[salsa::database(PanicSafelyStruct)] #[ra_salsa::database(PanicSafelyStruct)]
#[derive(Default)] #[derive(Default)]
struct DatabaseStruct { struct DatabaseStruct {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for DatabaseStruct {} impl ra_salsa::Database for DatabaseStruct {}
impl salsa::ParallelDatabase for DatabaseStruct { impl ra_salsa::ParallelDatabase for DatabaseStruct {
fn snapshot(&self) -> Snapshot<Self> { fn snapshot(&self) -> Snapshot<Self> {
Snapshot::new(DatabaseStruct { storage: self.storage.snapshot() }) Snapshot::new(DatabaseStruct { storage: self.storage.snapshot() })
} }

View file

@ -1,5 +1,5 @@
use crate::setup::{CancellationFlag, Knobs, ParDatabase, ParDatabaseImpl, WithValue}; use crate::setup::{CancellationFlag, Knobs, ParDatabase, ParDatabaseImpl, WithValue};
use salsa::{Cancelled, ParallelDatabase}; use ra_salsa::{Cancelled, ParallelDatabase};
macro_rules! assert_cancelled { macro_rules! assert_cancelled {
($thread:expr) => { ($thread:expr) => {
@ -96,7 +96,7 @@ fn in_par_get_set_cancellation_transitive() {
assert_eq!(thread2.join().unwrap(), 111); assert_eq!(thread2.join().unwrap(), 111);
} }
/// https://github.com/salsa-rs/salsa/issues/66 /// https://github.com/ra_salsa-rs/ra_salsa/issues/66
#[test] #[test]
fn no_back_dating_in_cancellation() { fn no_back_dating_in_cancellation() {
let mut db = ParDatabaseImpl::default(); let mut db = ParDatabaseImpl::default();

View file

@ -1,6 +1,6 @@
use crate::setup::{ParDatabase, ParDatabaseImpl}; use crate::setup::{ParDatabase, ParDatabaseImpl};
use crate::signal::Signal; use crate::signal::Signal;
use salsa::{Database, ParallelDatabase}; use ra_salsa::{Database, ParallelDatabase};
use std::{ use std::{
panic::{catch_unwind, AssertUnwindSafe}, panic::{catch_unwind, AssertUnwindSafe},
sync::Arc, sync::Arc,

View file

@ -1,5 +1,5 @@
use crate::setup::{ParDatabase, ParDatabaseImpl}; use crate::setup::{ParDatabase, ParDatabaseImpl};
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
/// Test two `sum` queries (on distinct keys) executing in different /// Test two `sum` queries (on distinct keys) executing in different
/// threads. Really just a test that `snapshot` etc compiles. /// threads. Really just a test that `snapshot` etc compiles.

View file

@ -3,7 +3,7 @@
//! both intra and cross thread. //! both intra and cross thread.
use crate::setup::{Knobs, ParDatabaseImpl}; use crate::setup::{Knobs, ParDatabaseImpl};
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
// Recover cycle test: // Recover cycle test:
// //
@ -46,37 +46,37 @@ fn parallel_cycle_all_recover() {
assert_eq!(thread_b.join().unwrap(), 21); assert_eq!(thread_b.join().unwrap(), 21);
} }
#[salsa::query_group(ParallelCycleAllRecover)] #[ra_salsa::query_group(ParallelCycleAllRecover)]
pub(crate) trait TestDatabase: Knobs { pub(crate) trait TestDatabase: Knobs {
#[salsa::cycle(recover_a1)] #[ra_salsa::cycle(recover_a1)]
fn a1(&self, key: i32) -> i32; fn a1(&self, key: i32) -> i32;
#[salsa::cycle(recover_a2)] #[ra_salsa::cycle(recover_a2)]
fn a2(&self, key: i32) -> i32; fn a2(&self, key: i32) -> i32;
#[salsa::cycle(recover_b1)] #[ra_salsa::cycle(recover_b1)]
fn b1(&self, key: i32) -> i32; fn b1(&self, key: i32) -> i32;
#[salsa::cycle(recover_b2)] #[ra_salsa::cycle(recover_b2)]
fn b2(&self, key: i32) -> i32; fn b2(&self, key: i32) -> i32;
} }
fn recover_a1(_db: &dyn TestDatabase, _cycle: &salsa::Cycle, key: &i32) -> i32 { fn recover_a1(_db: &dyn TestDatabase, _cycle: &ra_salsa::Cycle, key: &i32) -> i32 {
tracing::debug!("recover_a1"); tracing::debug!("recover_a1");
key * 10 + 1 key * 10 + 1
} }
fn recover_a2(_db: &dyn TestDatabase, _cycle: &salsa::Cycle, key: &i32) -> i32 { fn recover_a2(_db: &dyn TestDatabase, _cycle: &ra_salsa::Cycle, key: &i32) -> i32 {
tracing::debug!("recover_a2"); tracing::debug!("recover_a2");
key * 10 + 2 key * 10 + 2
} }
fn recover_b1(_db: &dyn TestDatabase, _cycle: &salsa::Cycle, key: &i32) -> i32 { fn recover_b1(_db: &dyn TestDatabase, _cycle: &ra_salsa::Cycle, key: &i32) -> i32 {
tracing::debug!("recover_b1"); tracing::debug!("recover_b1");
key * 20 + 1 key * 20 + 1
} }
fn recover_b2(_db: &dyn TestDatabase, _cycle: &salsa::Cycle, key: &i32) -> i32 { fn recover_b2(_db: &dyn TestDatabase, _cycle: &ra_salsa::Cycle, key: &i32) -> i32 {
tracing::debug!("recover_b2"); tracing::debug!("recover_b2");
key * 20 + 2 key * 20 + 2
} }

View file

@ -3,7 +3,7 @@
//! both intra and cross thread. //! both intra and cross thread.
use crate::setup::{Knobs, ParDatabaseImpl}; use crate::setup::{Knobs, ParDatabaseImpl};
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
// Recover cycle test: // Recover cycle test:
// //
@ -47,27 +47,27 @@ fn parallel_cycle_mid_recovers() {
assert_eq!(thread_b.join().unwrap(), 22); assert_eq!(thread_b.join().unwrap(), 22);
} }
#[salsa::query_group(ParallelCycleMidRecovers)] #[ra_salsa::query_group(ParallelCycleMidRecovers)]
pub(crate) trait TestDatabase: Knobs { pub(crate) trait TestDatabase: Knobs {
fn a1(&self, key: i32) -> i32; fn a1(&self, key: i32) -> i32;
fn a2(&self, key: i32) -> i32; fn a2(&self, key: i32) -> i32;
#[salsa::cycle(recover_b1)] #[ra_salsa::cycle(recover_b1)]
fn b1(&self, key: i32) -> i32; fn b1(&self, key: i32) -> i32;
fn b2(&self, key: i32) -> i32; fn b2(&self, key: i32) -> i32;
#[salsa::cycle(recover_b3)] #[ra_salsa::cycle(recover_b3)]
fn b3(&self, key: i32) -> i32; fn b3(&self, key: i32) -> i32;
} }
fn recover_b1(_db: &dyn TestDatabase, _cycle: &salsa::Cycle, key: &i32) -> i32 { fn recover_b1(_db: &dyn TestDatabase, _cycle: &ra_salsa::Cycle, key: &i32) -> i32 {
tracing::debug!("recover_b1"); tracing::debug!("recover_b1");
key * 20 + 2 key * 20 + 2
} }
fn recover_b3(_db: &dyn TestDatabase, _cycle: &salsa::Cycle, key: &i32) -> i32 { fn recover_b3(_db: &dyn TestDatabase, _cycle: &ra_salsa::Cycle, key: &i32) -> i32 {
tracing::debug!("recover_b1"); tracing::debug!("recover_b1");
key * 200 + 2 key * 200 + 2
} }

View file

@ -4,7 +4,7 @@
use crate::setup::{Knobs, ParDatabaseImpl}; use crate::setup::{Knobs, ParDatabaseImpl};
use expect_test::expect; use expect_test::expect;
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
#[test] #[test]
fn parallel_cycle_none_recover() { fn parallel_cycle_none_recover() {
@ -24,7 +24,7 @@ fn parallel_cycle_none_recover() {
// We expect B to panic because it detects a cycle (it is the one that calls A, ultimately). // We expect B to panic because it detects a cycle (it is the one that calls A, ultimately).
// Right now, it panics with a string. // Right now, it panics with a string.
let err_b = thread_b.join().unwrap_err(); let err_b = thread_b.join().unwrap_err();
if let Some(c) = err_b.downcast_ref::<salsa::Cycle>() { if let Some(c) = err_b.downcast_ref::<ra_salsa::Cycle>() {
expect![[r#" expect![[r#"
[ [
"parallel::parallel_cycle_none_recover::AQuery::a(-1)", "parallel::parallel_cycle_none_recover::AQuery::a(-1)",
@ -38,10 +38,10 @@ fn parallel_cycle_none_recover() {
// We expect A to propagate a panic, which causes us to use the sentinel // We expect A to propagate a panic, which causes us to use the sentinel
// type `Canceled`. // type `Canceled`.
assert!(thread_a.join().unwrap_err().downcast_ref::<salsa::Cycle>().is_some()); assert!(thread_a.join().unwrap_err().downcast_ref::<ra_salsa::Cycle>().is_some());
} }
#[salsa::query_group(ParallelCycleNoneRecover)] #[ra_salsa::query_group(ParallelCycleNoneRecover)]
pub(crate) trait TestDatabase: Knobs { pub(crate) trait TestDatabase: Knobs {
fn a(&self, key: i32) -> i32; fn a(&self, key: i32) -> i32;
fn b(&self, key: i32) -> i32; fn b(&self, key: i32) -> i32;

View file

@ -3,7 +3,7 @@
//! both intra and cross thread. //! both intra and cross thread.
use crate::setup::{Knobs, ParDatabaseImpl}; use crate::setup::{Knobs, ParDatabaseImpl};
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
// Recover cycle test: // Recover cycle test:
// //
@ -49,11 +49,11 @@ fn parallel_cycle_one_recovers() {
assert_eq!(thread_b.join().unwrap(), 22); assert_eq!(thread_b.join().unwrap(), 22);
} }
#[salsa::query_group(ParallelCycleOneRecovers)] #[ra_salsa::query_group(ParallelCycleOneRecovers)]
pub(crate) trait TestDatabase: Knobs { pub(crate) trait TestDatabase: Knobs {
fn a1(&self, key: i32) -> i32; fn a1(&self, key: i32) -> i32;
#[salsa::cycle(recover)] #[ra_salsa::cycle(recover)]
fn a2(&self, key: i32) -> i32; fn a2(&self, key: i32) -> i32;
fn b1(&self, key: i32) -> i32; fn b1(&self, key: i32) -> i32;
@ -61,7 +61,7 @@ pub(crate) trait TestDatabase: Knobs {
fn b2(&self, key: i32) -> i32; fn b2(&self, key: i32) -> i32;
} }
fn recover(_db: &dyn TestDatabase, _cycle: &salsa::Cycle, key: &i32) -> i32 { fn recover(_db: &dyn TestDatabase, _cycle: &ra_salsa::Cycle, key: &i32) -> i32 {
tracing::debug!("recover"); tracing::debug!("recover");
key * 20 + 2 key * 20 + 2
} }

View file

@ -1,7 +1,7 @@
use std::panic::AssertUnwindSafe; use std::panic::AssertUnwindSafe;
use crate::setup::{ParDatabase, ParDatabaseImpl}; use crate::setup::{ParDatabase, ParDatabaseImpl};
use salsa::{Cancelled, ParallelDatabase}; use ra_salsa::{Cancelled, ParallelDatabase};
/// Test where a read and a set are racing with one another. /// Test where a read and a set are racing with one another.
/// Should be atomic. /// Should be atomic.

View file

@ -1,16 +1,16 @@
use crate::signal::Signal; use crate::signal::Signal;
use salsa::Database; use ra_salsa::Database;
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
use salsa::Snapshot; use ra_salsa::Snapshot;
use std::sync::Arc; use std::sync::Arc;
use std::{ use std::{
cell::Cell, cell::Cell,
panic::{catch_unwind, resume_unwind, AssertUnwindSafe}, panic::{catch_unwind, resume_unwind, AssertUnwindSafe},
}; };
#[salsa::query_group(Par)] #[ra_salsa::query_group(Par)]
pub(crate) trait ParDatabase: Knobs { pub(crate) trait ParDatabase: Knobs {
#[salsa::input] #[ra_salsa::input]
fn input(&self, key: char) -> usize; fn input(&self, key: char) -> usize;
fn sum(&self, key: &'static str) -> usize; fn sum(&self, key: &'static str) -> usize;
@ -152,7 +152,7 @@ fn sum3_drop_sum(db: &dyn ParDatabase, key: &'static str) -> usize {
db.sum2_drop_sum(key) db.sum2_drop_sum(key)
} }
#[salsa::database( #[ra_salsa::database(
Par, Par,
crate::parallel_cycle_all_recover::ParallelCycleAllRecover, crate::parallel_cycle_all_recover::ParallelCycleAllRecover,
crate::parallel_cycle_none_recover::ParallelCycleNoneRecover, crate::parallel_cycle_none_recover::ParallelCycleNoneRecover,
@ -161,13 +161,13 @@ fn sum3_drop_sum(db: &dyn ParDatabase, key: &'static str) -> usize {
)] )]
#[derive(Default)] #[derive(Default)]
pub(crate) struct ParDatabaseImpl { pub(crate) struct ParDatabaseImpl {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
knobs: KnobsStruct, knobs: KnobsStruct,
} }
impl Database for ParDatabaseImpl { impl Database for ParDatabaseImpl {
fn salsa_event(&self, event: salsa::Event) { fn salsa_event(&self, event: ra_salsa::Event) {
if let salsa::EventKind::WillBlockOn { .. } = event.kind { if let ra_salsa::EventKind::WillBlockOn { .. } = event.kind {
self.signal(self.knobs().signal_on_will_block.get()); self.signal(self.knobs().signal_on_will_block.get());
} }
} }

View file

@ -1,17 +1,17 @@
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use rand::Rng; use rand::Rng;
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
use salsa::Snapshot; use ra_salsa::Snapshot;
use salsa::{Cancelled, Database}; use ra_salsa::{Cancelled, Database};
// Number of operations a reader performs // Number of operations a reader performs
const N_MUTATOR_OPS: usize = 100; const N_MUTATOR_OPS: usize = 100;
const N_READER_OPS: usize = 100; const N_READER_OPS: usize = 100;
#[salsa::query_group(Stress)] #[ra_salsa::query_group(Stress)]
trait StressDatabase: salsa::Database { trait StressDatabase: ra_salsa::Database {
#[salsa::input] #[ra_salsa::input]
fn a(&self, key: usize) -> usize; fn a(&self, key: usize) -> usize;
fn b(&self, key: usize) -> usize; fn b(&self, key: usize) -> usize;
@ -28,15 +28,15 @@ fn c(db: &dyn StressDatabase, key: usize) -> usize {
db.b(key) db.b(key)
} }
#[salsa::database(Stress)] #[ra_salsa::database(Stress)]
#[derive(Default)] #[derive(Default)]
struct StressDatabaseImpl { struct StressDatabaseImpl {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for StressDatabaseImpl {} impl ra_salsa::Database for StressDatabaseImpl {}
impl salsa::ParallelDatabase for StressDatabaseImpl { impl ra_salsa::ParallelDatabase for StressDatabaseImpl {
fn snapshot(&self) -> Snapshot<StressDatabaseImpl> { fn snapshot(&self) -> Snapshot<StressDatabaseImpl> {
Snapshot::new(StressDatabaseImpl { storage: self.storage.snapshot() }) Snapshot::new(StressDatabaseImpl { storage: self.storage.snapshot() })
} }

View file

@ -1,5 +1,5 @@
use crate::setup::{Knobs, ParDatabase, ParDatabaseImpl, WithValue}; use crate::setup::{Knobs, ParDatabase, ParDatabaseImpl, WithValue};
use salsa::ParallelDatabase; use ra_salsa::ParallelDatabase;
use std::panic::{self, AssertUnwindSafe}; use std::panic::{self, AssertUnwindSafe};
/// Test where two threads are executing sum. We show that they can /// Test where two threads are executing sum. We show that they can

View file

@ -1,10 +1,10 @@
use crate::queries; use crate::queries;
use std::cell::Cell; use std::cell::Cell;
#[salsa::database(queries::GroupStruct)] #[ra_salsa::database(queries::GroupStruct)]
#[derive(Default)] #[derive(Default)]
pub(crate) struct DatabaseImpl { pub(crate) struct DatabaseImpl {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
counter: Cell<usize>, counter: Cell<usize>,
} }
@ -16,4 +16,4 @@ impl queries::Counter for DatabaseImpl {
} }
} }
impl salsa::Database for DatabaseImpl {} impl ra_salsa::Database for DatabaseImpl {}

View file

@ -1,8 +1,8 @@
pub(crate) trait Counter: salsa::Database { pub(crate) trait Counter: ra_salsa::Database {
fn increment(&self) -> usize; fn increment(&self) -> usize;
} }
#[salsa::query_group(GroupStruct)] #[ra_salsa::query_group(GroupStruct)]
pub(crate) trait Database: Counter { pub(crate) trait Database: Counter {
fn memoized(&self) -> usize; fn memoized(&self) -> usize;
fn volatile(&self) -> usize; fn volatile(&self) -> usize;

View file

@ -2,8 +2,8 @@
use crate::implementation::DatabaseImpl; use crate::implementation::DatabaseImpl;
use crate::queries::Database; use crate::queries::Database;
use salsa::Database as _Database; use ra_salsa::Database as _Database;
use salsa::Durability; use ra_salsa::Durability;
#[test] #[test]
fn memoized_twice() { fn memoized_twice() {

View file

@ -1,10 +1,10 @@
//! Test that transparent (uncached) queries work //! Test that transparent (uncached) queries work
#[salsa::query_group(QueryGroupStorage)] #[ra_salsa::query_group(QueryGroupStorage)]
trait QueryGroup { trait QueryGroup {
#[salsa::input] #[ra_salsa::input]
fn input(&self, x: u32) -> u32; fn input(&self, x: u32) -> u32;
#[salsa::transparent] #[ra_salsa::transparent]
fn wrap(&self, x: u32) -> u32; fn wrap(&self, x: u32) -> u32;
fn get(&self, x: u32) -> u32; fn get(&self, x: u32) -> u32;
} }
@ -17,13 +17,13 @@ fn get(db: &dyn QueryGroup, x: u32) -> u32 {
db.wrap(x) db.wrap(x)
} }
#[salsa::database(QueryGroupStorage)] #[ra_salsa::database(QueryGroupStorage)]
#[derive(Default)] #[derive(Default)]
struct Database { struct Database {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for Database {} impl ra_salsa::Database for Database {}
#[test] #[test]
fn transparent_queries_work() { fn transparent_queries_work() {

View file

@ -1,6 +1,6 @@
#[salsa::query_group(HelloWorld)] #[ra_salsa::query_group(HelloWorld)]
trait HelloWorldDatabase: salsa::Database { trait HelloWorldDatabase: ra_salsa::Database {
#[salsa::input] #[ra_salsa::input]
fn input(&self, a: u32, b: u32) -> u32; fn input(&self, a: u32, b: u32) -> u32;
fn none(&self) -> u32; fn none(&self) -> u32;
@ -28,13 +28,13 @@ fn trailing(_db: &dyn HelloWorldDatabase, a: u32, b: u32) -> u32 {
a - b a - b
} }
#[salsa::database(HelloWorld)] #[ra_salsa::database(HelloWorld)]
#[derive(Default)] #[derive(Default)]
struct DatabaseStruct { struct DatabaseStruct {
storage: salsa::Storage<Self>, storage: ra_salsa::Storage<Self>,
} }
impl salsa::Database for DatabaseStruct {} impl ra_salsa::Database for DatabaseStruct {}
#[test] #[test]
fn execute() { fn execute() {

View file

@ -22,7 +22,7 @@ use ide::{
}; };
use ide_db::{ use ide_db::{
base_db::{ base_db::{
salsa::{self, debug::DebugQueryTable, ParallelDatabase}, ra_salsa::{self, debug::DebugQueryTable, ParallelDatabase},
SourceDatabase, SourceRootDatabase, SourceDatabase, SourceRootDatabase,
}, },
EditionedFileId, LineIndexDatabase, SnippetCap, EditionedFileId, LineIndexDatabase, SnippetCap,
@ -46,8 +46,8 @@ use crate::cli::{
/// Need to wrap Snapshot to provide `Clone` impl for `map_with` /// Need to wrap Snapshot to provide `Clone` impl for `map_with`
struct Snap<DB>(DB); struct Snap<DB>(DB);
impl<DB: ParallelDatabase> Clone for Snap<salsa::Snapshot<DB>> { impl<DB: ParallelDatabase> Clone for Snap<ra_salsa::Snapshot<DB>> {
fn clone(&self) -> Snap<salsa::Snapshot<DB>> { fn clone(&self) -> Snap<ra_salsa::Snapshot<DB>> {
Snap(self.0.snapshot()) Snap(self.0.snapshot())
} }
} }

View file

@ -18,7 +18,7 @@ use std::{iter, mem};
use hir::{db::DefDatabase, ChangeWithProcMacros, ProcMacros, ProcMacrosBuilder}; use hir::{db::DefDatabase, ChangeWithProcMacros, ProcMacros, ProcMacrosBuilder};
use ide::CrateId; use ide::CrateId;
use ide_db::{ use ide_db::{
base_db::{salsa::Durability, CrateGraph, CrateWorkspaceData, ProcMacroPaths}, base_db::{ra_salsa::Durability, CrateGraph, CrateWorkspaceData, ProcMacroPaths},
FxHashMap, FxHashMap,
}; };
use itertools::Itertools; use itertools::Itertools;

Some files were not shown because too many files have changed in this diff Show more