mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Split out salsa_macros
Does not do much yet due to tracing pulling syn but oh well
This commit is contained in:
parent
9fa647c129
commit
996d6ed1a3
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -85,6 +85,7 @@ dependencies = [
|
|||||||
"query-group-macro",
|
"query-group-macro",
|
||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
"salsa",
|
"salsa",
|
||||||
|
"salsa-macros",
|
||||||
"semver",
|
"semver",
|
||||||
"span",
|
"span",
|
||||||
"syntax",
|
"syntax",
|
||||||
@ -630,6 +631,7 @@ dependencies = [
|
|||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
"rustc_apfloat",
|
"rustc_apfloat",
|
||||||
"salsa",
|
"salsa",
|
||||||
|
"salsa-macros",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
@ -660,6 +662,7 @@ dependencies = [
|
|||||||
"query-group-macro",
|
"query-group-macro",
|
||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
"salsa",
|
"salsa",
|
||||||
|
"salsa-macros",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
@ -700,6 +703,7 @@ dependencies = [
|
|||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
"rustc_apfloat",
|
"rustc_apfloat",
|
||||||
"salsa",
|
"salsa",
|
||||||
|
"salsa-macros",
|
||||||
"scoped-tls",
|
"scoped-tls",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"span",
|
"span",
|
||||||
@ -936,6 +940,7 @@ dependencies = [
|
|||||||
"rayon",
|
"rayon",
|
||||||
"rustc-hash 2.1.1",
|
"rustc-hash 2.1.1",
|
||||||
"salsa",
|
"salsa",
|
||||||
|
"salsa-macros",
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
@ -1729,6 +1734,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"salsa",
|
"salsa",
|
||||||
|
"salsa-macros",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ process-wrap = { version = "8.2.0", features = ["std"] }
|
|||||||
pulldown-cmark-to-cmark = "10.0.4"
|
pulldown-cmark-to-cmark = "10.0.4"
|
||||||
pulldown-cmark = { version = "0.9.6", default-features = false }
|
pulldown-cmark = { version = "0.9.6", default-features = false }
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
salsa = "0.21.0"
|
salsa = { version = "0.21.0", default-features = false, features = ["rayon","salsa_unstable"] }
|
||||||
|
salsa-macros = "0.21.0"
|
||||||
semver = "1.0.26"
|
semver = "1.0.26"
|
||||||
serde = { version = "1.0.219" }
|
serde = { version = "1.0.219" }
|
||||||
serde_derive = { version = "1.0.219" }
|
serde_derive = { version = "1.0.219" }
|
||||||
|
@ -15,6 +15,7 @@ rust-version.workspace = true
|
|||||||
la-arena.workspace = true
|
la-arena.workspace = true
|
||||||
dashmap.workspace = true
|
dashmap.workspace = true
|
||||||
salsa.workspace = true
|
salsa.workspace = true
|
||||||
|
salsa-macros.workspace = true
|
||||||
query-group.workspace = true
|
query-group.workspace = true
|
||||||
rustc-hash.workspace = true
|
rustc-hash.workspace = true
|
||||||
triomphe.workspace = true
|
triomphe.workspace = true
|
||||||
|
@ -392,7 +392,7 @@ impl BuiltDependency {
|
|||||||
|
|
||||||
pub type CratesIdMap = FxHashMap<CrateBuilderId, Crate>;
|
pub type CratesIdMap = FxHashMap<CrateBuilderId, Crate>;
|
||||||
|
|
||||||
#[salsa::input]
|
#[salsa_macros::input]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Crate {
|
pub struct Crate {
|
||||||
#[return_ref]
|
#[return_ref]
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
//! base_db defines basic database traits. The concrete DB is defined by ide.
|
//! base_db defines basic database traits. The concrete DB is defined by ide.
|
||||||
|
|
||||||
|
pub use salsa;
|
||||||
|
pub use salsa_macros;
|
||||||
|
|
||||||
// FIXME: Rename this crate, base db is non descriptive
|
// FIXME: Rename this crate, base db is non descriptive
|
||||||
mod change;
|
mod change;
|
||||||
mod input;
|
mod input;
|
||||||
@ -17,7 +21,6 @@ pub use crate::{
|
|||||||
use dashmap::{DashMap, mapref::entry::Entry};
|
use dashmap::{DashMap, mapref::entry::Entry};
|
||||||
pub use query_group::{self};
|
pub use query_group::{self};
|
||||||
use rustc_hash::{FxHashSet, FxHasher};
|
use rustc_hash::{FxHashSet, FxHasher};
|
||||||
pub use salsa::{self};
|
|
||||||
use salsa::{Durability, Setter};
|
use salsa::{Durability, Setter};
|
||||||
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
|
pub use semver::{BuildMetadata, Prerelease, Version, VersionReq};
|
||||||
use span::Edition;
|
use span::Edition;
|
||||||
@ -28,7 +31,7 @@ pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet}
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_intern_key {
|
macro_rules! impl_intern_key {
|
||||||
($id:ident, $loc:ident) => {
|
($id:ident, $loc:ident) => {
|
||||||
#[salsa::interned(no_lifetime)]
|
#[salsa_macros::interned(no_lifetime)]
|
||||||
pub struct $id {
|
pub struct $id {
|
||||||
pub loc: $loc,
|
pub loc: $loc,
|
||||||
}
|
}
|
||||||
@ -161,7 +164,7 @@ impl Files {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::interned(no_lifetime, debug, constructor=from_span)]
|
#[salsa_macros::interned(no_lifetime, debug, constructor=from_span)]
|
||||||
pub struct EditionedFileId {
|
pub struct EditionedFileId {
|
||||||
pub editioned_file_id: span::EditionedFileId,
|
pub editioned_file_id: span::EditionedFileId,
|
||||||
}
|
}
|
||||||
@ -196,18 +199,18 @@ impl EditionedFileId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::input(debug)]
|
#[salsa_macros::input(debug)]
|
||||||
pub struct FileText {
|
pub struct FileText {
|
||||||
pub text: Arc<str>,
|
pub text: Arc<str>,
|
||||||
pub file_id: vfs::FileId,
|
pub file_id: vfs::FileId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::input(debug)]
|
#[salsa_macros::input(debug)]
|
||||||
pub struct FileSourceRootInput {
|
pub struct FileSourceRootInput {
|
||||||
pub source_root_id: SourceRootId,
|
pub source_root_id: SourceRootId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::input(debug)]
|
#[salsa_macros::input(debug)]
|
||||||
pub struct SourceRootInput {
|
pub struct SourceRootInput {
|
||||||
pub source_root: Arc<SourceRoot>,
|
pub source_root: Arc<SourceRoot>,
|
||||||
}
|
}
|
||||||
@ -274,7 +277,7 @@ pub fn transitive_deps(db: &dyn SourceDatabase, crate_id: Crate) -> FxHashSet<Cr
|
|||||||
deps
|
deps
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
pub trait SourceDatabase: salsa::Database {
|
pub trait SourceDatabase: salsa::Database {
|
||||||
/// Text of the file.
|
/// Text of the file.
|
||||||
fn file_text(&self, file_id: vfs::FileId) -> FileText;
|
fn file_text(&self, file_id: vfs::FileId) -> FileText;
|
||||||
@ -353,7 +356,7 @@ fn parse(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Parse<ast::SourceFil
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<&[SyntaxError]> {
|
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<&[SyntaxError]> {
|
||||||
#[salsa::tracked(return_ref)]
|
#[salsa_macros::tracked(return_ref)]
|
||||||
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<Box<[SyntaxError]>> {
|
fn parse_errors(db: &dyn RootQueryDb, file_id: EditionedFileId) -> Option<Box<[SyntaxError]>> {
|
||||||
let errors = db.parse(file_id).errors();
|
let errors = db.parse(file_id).errors();
|
||||||
match &*errors {
|
match &*errors {
|
||||||
|
@ -28,6 +28,7 @@ triomphe.workspace = true
|
|||||||
rustc_apfloat = "0.2.2"
|
rustc_apfloat = "0.2.2"
|
||||||
text-size.workspace = true
|
text-size.workspace = true
|
||||||
salsa.workspace = true
|
salsa.workspace = true
|
||||||
|
salsa-macros.workspace = true
|
||||||
query-group.workspace = true
|
query-group.workspace = true
|
||||||
|
|
||||||
ra-ap-rustc_parse_format.workspace = true
|
ra-ap-rustc_parse_format.workspace = true
|
||||||
|
@ -84,7 +84,7 @@ impl LangItemTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Salsa query. This will look for lang items in a specific crate.
|
/// Salsa query. This will look for lang items in a specific crate.
|
||||||
#[salsa::tracked(return_ref)]
|
#[salsa_macros::tracked(return_ref)]
|
||||||
pub fn crate_lang_items(db: &dyn DefDatabase, krate: Crate) -> Option<Box<LangItems>> {
|
pub fn crate_lang_items(db: &dyn DefDatabase, krate: Crate) -> Option<Box<LangItems>> {
|
||||||
let _p = tracing::info_span!("crate_lang_items_query").entered();
|
let _p = tracing::info_span!("crate_lang_items_query").entered();
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ pub fn crate_lang_items(db: &dyn DefDatabase, krate: Crate) -> Option<Box<LangIt
|
|||||||
|
|
||||||
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
|
/// Salsa query. Look for a lang item, starting from the specified crate and recursively
|
||||||
/// traversing its dependencies.
|
/// traversing its dependencies.
|
||||||
#[salsa::tracked]
|
#[salsa_macros::tracked]
|
||||||
pub fn lang_item(
|
pub fn lang_item(
|
||||||
db: &dyn DefDatabase,
|
db: &dyn DefDatabase,
|
||||||
start_crate: Crate,
|
start_crate: Crate,
|
||||||
|
@ -554,7 +554,7 @@ pub enum ItemContainerId {
|
|||||||
impl_from!(ModuleId for ItemContainerId);
|
impl_from!(ModuleId for ItemContainerId);
|
||||||
|
|
||||||
/// A Data Type
|
/// A Data Type
|
||||||
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum AdtId {
|
pub enum AdtId {
|
||||||
StructId(StructId),
|
StructId(StructId),
|
||||||
UnionId(UnionId),
|
UnionId(UnionId),
|
||||||
@ -563,7 +563,7 @@ pub enum AdtId {
|
|||||||
impl_from!(StructId, UnionId, EnumId for AdtId);
|
impl_from!(StructId, UnionId, EnumId for AdtId);
|
||||||
|
|
||||||
/// A macro
|
/// A macro
|
||||||
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum MacroId {
|
pub enum MacroId {
|
||||||
Macro2Id(Macro2Id),
|
Macro2Id(Macro2Id),
|
||||||
MacroRulesId(MacroRulesId),
|
MacroRulesId(MacroRulesId),
|
||||||
@ -619,7 +619,7 @@ impl_from!(
|
|||||||
|
|
||||||
/// A constant, which might appears as a const item, an anonymous const block in expressions
|
/// A constant, which might appears as a const item, an anonymous const block in expressions
|
||||||
/// or patterns, or as a constant in types with const generics.
|
/// or patterns, or as a constant in types with const generics.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum GeneralConstId {
|
pub enum GeneralConstId {
|
||||||
ConstId(ConstId),
|
ConstId(ConstId),
|
||||||
StaticId(StaticId),
|
StaticId(StaticId),
|
||||||
@ -656,7 +656,7 @@ impl GeneralConstId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The defs which have a body (have root expressions for type inference).
|
/// The defs which have a body (have root expressions for type inference).
|
||||||
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum DefWithBodyId {
|
pub enum DefWithBodyId {
|
||||||
FunctionId(FunctionId),
|
FunctionId(FunctionId),
|
||||||
StaticId(StaticId),
|
StaticId(StaticId),
|
||||||
@ -701,7 +701,7 @@ pub enum AssocItemId {
|
|||||||
// casting them, and somehow making the constructors private, which would be annoying.
|
// casting them, and somehow making the constructors private, which would be annoying.
|
||||||
impl_from!(FunctionId, ConstId, TypeAliasId for AssocItemId);
|
impl_from!(FunctionId, ConstId, TypeAliasId for AssocItemId);
|
||||||
|
|
||||||
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum GenericDefId {
|
pub enum GenericDefId {
|
||||||
AdtId(AdtId),
|
AdtId(AdtId),
|
||||||
// consts can have type parameters from their parents (i.e. associated consts of traits)
|
// consts can have type parameters from their parents (i.e. associated consts of traits)
|
||||||
@ -790,7 +790,7 @@ impl From<AssocItemId> for GenericDefId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, PartialOrd, Ord, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum CallableDefId {
|
pub enum CallableDefId {
|
||||||
FunctionId(FunctionId),
|
FunctionId(FunctionId),
|
||||||
StructId(StructId),
|
StructId(StructId),
|
||||||
@ -906,7 +906,7 @@ impl From<VariantId> for AttrDefId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum VariantId {
|
pub enum VariantId {
|
||||||
EnumVariantId(EnumVariantId),
|
EnumVariantId(EnumVariantId),
|
||||||
StructId(StructId),
|
StructId(StructId),
|
||||||
|
@ -19,7 +19,7 @@ use crate::{
|
|||||||
src::HasSource,
|
src::HasSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct TestDB {
|
pub(crate) struct TestDB {
|
||||||
storage: salsa::Storage<Self>,
|
storage: salsa::Storage<Self>,
|
||||||
@ -44,7 +44,7 @@ impl Default for TestDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl salsa::Database for TestDB {
|
impl salsa::Database for TestDB {
|
||||||
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
|
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
|
||||||
let mut events = self.events.lock().unwrap();
|
let mut events = self.events.lock().unwrap();
|
||||||
@ -63,7 +63,7 @@ impl fmt::Debug for TestDB {
|
|||||||
|
|
||||||
impl panic::RefUnwindSafe for TestDB {}
|
impl panic::RefUnwindSafe for TestDB {}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl SourceDatabase for TestDB {
|
impl SourceDatabase for TestDB {
|
||||||
fn file_text(&self, file_id: base_db::FileId) -> FileText {
|
fn file_text(&self, file_id: base_db::FileId) -> FileText {
|
||||||
self.files.file_text(file_id)
|
self.files.file_text(file_id)
|
||||||
|
@ -21,6 +21,7 @@ smallvec.workspace = true
|
|||||||
triomphe.workspace = true
|
triomphe.workspace = true
|
||||||
query-group.workspace = true
|
query-group.workspace = true
|
||||||
salsa.workspace = true
|
salsa.workspace = true
|
||||||
|
salsa-macros.workspace = true
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
stdx.workspace = true
|
stdx.workspace = true
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
//! 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::{CrateGraphBuilder, FileChange, SourceRoot};
|
use base_db::{CrateGraphBuilder, FileChange, SourceRoot, salsa::Durability};
|
||||||
use salsa::Durability;
|
|
||||||
use span::FileId;
|
use span::FileId;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ pub trait ExpandDatabase: RootQueryDb {
|
|||||||
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContext;
|
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::interned(no_lifetime, id = span::SyntaxContext)]
|
#[salsa_macros::interned(no_lifetime, id = span::SyntaxContext)]
|
||||||
pub struct SyntaxContextWrapper {
|
pub struct SyntaxContextWrapper {
|
||||||
pub data: SyntaxContext,
|
pub data: SyntaxContext,
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1050,7 @@ impl ExpandTo {
|
|||||||
|
|
||||||
intern::impl_internable!(ModPath, attrs::AttrInput);
|
intern::impl_internable!(ModPath, attrs::AttrInput);
|
||||||
|
|
||||||
#[salsa::interned(no_lifetime, debug)]
|
#[salsa_macros::interned(no_lifetime, debug)]
|
||||||
#[doc(alias = "MacroFileId")]
|
#[doc(alias = "MacroFileId")]
|
||||||
pub struct MacroCallId {
|
pub struct MacroCallId {
|
||||||
pub loc: MacroCallLoc,
|
pub loc: MacroCallLoc,
|
||||||
@ -1070,7 +1070,7 @@ impl From<MacroCallId> for span::MacroCallId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum HirFileId {
|
pub enum HirFileId {
|
||||||
FileId(EditionedFileId),
|
FileId(EditionedFileId),
|
||||||
MacroFile(MacroCallId),
|
MacroFile(MacroCallId),
|
||||||
|
@ -34,6 +34,7 @@ indexmap.workspace = true
|
|||||||
rustc_apfloat = "0.2.2"
|
rustc_apfloat = "0.2.2"
|
||||||
query-group.workspace = true
|
query-group.workspace = true
|
||||||
salsa.workspace = true
|
salsa.workspace = true
|
||||||
|
salsa-macros.workspace = true
|
||||||
|
|
||||||
ra-ap-rustc_abi.workspace = true
|
ra-ap-rustc_abi.workspace = true
|
||||||
ra-ap-rustc_index.workspace = true
|
ra-ap-rustc_index.workspace = true
|
||||||
|
@ -1468,7 +1468,7 @@ fn type_for_enum_variant_constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::tracked(cycle_result = type_for_adt_cycle_result)]
|
#[salsa_macros::tracked(cycle_result = type_for_adt_cycle_result)]
|
||||||
fn type_for_adt_tracked(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> {
|
fn type_for_adt_tracked(db: &dyn HirDatabase, adt: AdtId) -> Binders<Ty> {
|
||||||
type_for_adt(db, adt)
|
type_for_adt(db, adt)
|
||||||
}
|
}
|
||||||
@ -1533,7 +1533,7 @@ pub enum TyDefId {
|
|||||||
}
|
}
|
||||||
impl_from!(BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId for TyDefId);
|
impl_from!(BuiltinType, AdtId(StructId, EnumId, UnionId), TypeAliasId for TyDefId);
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa_macros::Supertype)]
|
||||||
pub enum ValueTyDefId {
|
pub enum ValueTyDefId {
|
||||||
FunctionId(FunctionId),
|
FunctionId(FunctionId),
|
||||||
StructId(StructId),
|
StructId(StructId),
|
||||||
|
@ -16,7 +16,7 @@ use syntax::TextRange;
|
|||||||
use test_utils::extract_annotations;
|
use test_utils::extract_annotations;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct TestDB {
|
pub(crate) struct TestDB {
|
||||||
storage: salsa::Storage<Self>,
|
storage: salsa::Storage<Self>,
|
||||||
@ -47,7 +47,7 @@ impl fmt::Debug for TestDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl SourceDatabase for TestDB {
|
impl SourceDatabase for TestDB {
|
||||||
fn file_text(&self, file_id: base_db::FileId) -> FileText {
|
fn file_text(&self, file_id: base_db::FileId) -> FileText {
|
||||||
self.files.file_text(file_id)
|
self.files.file_text(file_id)
|
||||||
@ -102,7 +102,7 @@ impl SourceDatabase for TestDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl salsa::Database for TestDB {
|
impl salsa::Database for TestDB {
|
||||||
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
|
fn salsa_event(&self, event: &dyn std::ops::Fn() -> salsa::Event) {
|
||||||
let mut events = self.events.lock().unwrap();
|
let mut events = self.events.lock().unwrap();
|
||||||
|
@ -24,6 +24,7 @@ arrayvec.workspace = true
|
|||||||
indexmap.workspace = true
|
indexmap.workspace = true
|
||||||
memchr = "2.7.4"
|
memchr = "2.7.4"
|
||||||
salsa.workspace = true
|
salsa.workspace = true
|
||||||
|
salsa-macros.workspace = true
|
||||||
query-group.workspace = true
|
query-group.workspace = true
|
||||||
triomphe.workspace = true
|
triomphe.workspace = true
|
||||||
nohash-hasher.workspace = true
|
nohash-hasher.workspace = true
|
||||||
|
@ -76,7 +76,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::db]
|
#[salsa_macros::db]
|
||||||
pub struct RootDatabase {
|
pub struct RootDatabase {
|
||||||
// FIXME: Revisit this commit now that we migrated to the new salsa, given we store arcs in this
|
// FIXME: Revisit this commit now that we migrated to the new salsa, given we store arcs in this
|
||||||
// db directly now
|
// db directly now
|
||||||
@ -91,7 +91,7 @@ pub struct RootDatabase {
|
|||||||
|
|
||||||
impl std::panic::RefUnwindSafe for RootDatabase {}
|
impl std::panic::RefUnwindSafe for RootDatabase {}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl salsa::Database for RootDatabase {
|
impl salsa::Database for RootDatabase {
|
||||||
fn salsa_event(&self, _event: &dyn Fn() -> salsa::Event) {}
|
fn salsa_event(&self, _event: &dyn Fn() -> salsa::Event) {}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ impl fmt::Debug for RootDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl SourceDatabase for RootDatabase {
|
impl SourceDatabase for RootDatabase {
|
||||||
fn file_text(&self, file_id: vfs::FileId) -> FileText {
|
fn file_text(&self, file_id: vfs::FileId) -> FileText {
|
||||||
self.files.file_text(file_id)
|
self.files.file_text(file_id)
|
||||||
|
@ -20,3 +20,4 @@ syn = { version = "2.0", features = ["full", "extra-traits", "visit-mut"] }
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
expect-test = "1.5.1"
|
expect-test = "1.5.1"
|
||||||
salsa.workspace = true
|
salsa.workspace = true
|
||||||
|
salsa-macros.workspace = true
|
||||||
|
@ -178,7 +178,7 @@ pub(crate) fn query_group_impl(
|
|||||||
let supertraits = &item_trait.supertraits;
|
let supertraits = &item_trait.supertraits;
|
||||||
|
|
||||||
let db_attr: Attribute = parse_quote! {
|
let db_attr: Attribute = parse_quote! {
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
};
|
};
|
||||||
item_trait.attrs.push(db_attr);
|
item_trait.attrs.push(db_attr);
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ pub(crate) fn query_group_impl(
|
|||||||
.collect::<Vec<proc_macro2::TokenStream>>();
|
.collect::<Vec<proc_macro2::TokenStream>>();
|
||||||
|
|
||||||
let input_struct = quote! {
|
let input_struct = quote! {
|
||||||
#[salsa::input]
|
#[salsa_macros::input]
|
||||||
pub(crate) struct #input_struct_name {
|
pub(crate) struct #input_struct_name {
|
||||||
#(#fields),*
|
#(#fields),*
|
||||||
}
|
}
|
||||||
@ -418,7 +418,7 @@ pub(crate) fn query_group_impl(
|
|||||||
|
|
||||||
let create_data_method = quote! {
|
let create_data_method = quote! {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[salsa::tracked]
|
#[salsa_macros::tracked]
|
||||||
fn #create_data_ident(db: &dyn #trait_name_ident) -> #input_struct_name {
|
fn #create_data_ident(db: &dyn #trait_name_ident) -> #input_struct_name {
|
||||||
#input_struct_name::new(db, #(#field_params),*)
|
#input_struct_name::new(db, #(#field_params),*)
|
||||||
}
|
}
|
||||||
@ -443,7 +443,7 @@ pub(crate) fn query_group_impl(
|
|||||||
item_trait.items.append(&mut lookup_signatures);
|
item_trait.items.append(&mut lookup_signatures);
|
||||||
|
|
||||||
let trait_impl = quote! {
|
let trait_impl = quote! {
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl<DB> #trait_name_ident for DB
|
impl<DB> #trait_name_ident for DB
|
||||||
where
|
where
|
||||||
DB: #supertraits,
|
DB: #supertraits,
|
||||||
|
@ -49,7 +49,7 @@ impl ToTokens for TrackedQuery {
|
|||||||
})
|
})
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(self.lru.map(|lru| quote!(lru = #lru)));
|
.chain(self.lru.map(|lru| quote!(lru = #lru)));
|
||||||
let annotation = quote!(#[salsa::tracked( #(#options),* )]);
|
let annotation = quote!(#[salsa_macros::tracked( #(#options),* )]);
|
||||||
|
|
||||||
let pat_and_tys = &self.pat_and_tys;
|
let pat_and_tys = &self.pat_and_tys;
|
||||||
let params = self
|
let params = self
|
||||||
|
@ -6,7 +6,7 @@ use salsa::plumbing::AsId;
|
|||||||
mod logger_db;
|
mod logger_db;
|
||||||
use logger_db::LoggerDb;
|
use logger_db::LoggerDb;
|
||||||
|
|
||||||
#[salsa::interned(no_lifetime)]
|
#[salsa_macros::interned(no_lifetime)]
|
||||||
pub struct InternedString {
|
pub struct InternedString {
|
||||||
data: String,
|
data: String,
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
#[derive(Default, Clone)]
|
#[derive(Default, Clone)]
|
||||||
pub(crate) struct LoggerDb {
|
pub(crate) struct LoggerDb {
|
||||||
storage: salsa::Storage<Self>,
|
storage: salsa::Storage<Self>,
|
||||||
@ -12,7 +12,7 @@ struct Logger {
|
|||||||
logs: Arc<Mutex<Vec<String>>>,
|
logs: Arc<Mutex<Vec<String>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
impl salsa::Database for LoggerDb {
|
impl salsa::Database for LoggerDb {
|
||||||
fn salsa_event(&self, event: &dyn Fn() -> salsa::Event) {
|
fn salsa_event(&self, event: &dyn Fn() -> salsa::Event) {
|
||||||
let event = event();
|
let event = event();
|
||||||
|
@ -4,7 +4,7 @@ mod logger_db;
|
|||||||
use logger_db::LoggerDb;
|
use logger_db::LoggerDb;
|
||||||
use query_group_macro::query_group;
|
use query_group_macro::query_group;
|
||||||
|
|
||||||
#[salsa::input]
|
#[salsa_macros::input]
|
||||||
struct Input {
|
struct Input {
|
||||||
str: String,
|
str: String,
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ fn invoke_length_query_actual(db: &dyn PartialMigrationDatabase, input: Input) -
|
|||||||
input.str(db).len()
|
input.str(db).len()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::tracked]
|
#[salsa_macros::tracked]
|
||||||
fn invoke_length_tracked_actual(db: &dyn PartialMigrationDatabase, input: Input) -> usize {
|
fn invoke_length_tracked_actual(db: &dyn PartialMigrationDatabase, input: Input) -> usize {
|
||||||
input.str(db).len()
|
input.str(db).len()
|
||||||
}
|
}
|
||||||
@ -87,12 +87,12 @@ fn invoke_tracked_query() {
|
|||||||
fn new_salsa_baseline() {
|
fn new_salsa_baseline() {
|
||||||
let db = LoggerDb::default();
|
let db = LoggerDb::default();
|
||||||
|
|
||||||
#[salsa::input]
|
#[salsa_macros::input]
|
||||||
struct Input {
|
struct Input {
|
||||||
str: String,
|
str: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::tracked]
|
#[salsa_macros::tracked]
|
||||||
fn new_salsa_length_query(db: &dyn PartialMigrationDatabase, input: Input) -> usize {
|
fn new_salsa_length_query(db: &dyn PartialMigrationDatabase, input: Input) -> usize {
|
||||||
input.str(db).len()
|
input.str(db).len()
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use query_group_macro::query_group;
|
use query_group_macro::query_group;
|
||||||
|
|
||||||
#[salsa::db]
|
#[salsa_macros::db]
|
||||||
pub trait SourceDb: salsa::Database {
|
pub trait SourceDb: salsa::Database {
|
||||||
/// Text of the file.
|
/// Text of the file.
|
||||||
fn file_text(&self, id: usize) -> String;
|
fn file_text(&self, id: usize) -> String;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user