internal: bump salsa to 0.24
This commit is contained in:
parent
30796a0db3
commit
3350c27d91
7 changed files with 288 additions and 282 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -137,12 +137,13 @@ rayon = "1.10.0"
|
|||
rowan = "=0.15.15"
|
||||
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
|
||||
# on impls without it
|
||||
salsa = { version = "0.23.0", default-features = true, features = [
|
||||
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "e257df12eabd566825ba53bb12d782560b9a4dcd", default-features = true, features = [
|
||||
"rayon",
|
||||
"salsa_unstable",
|
||||
"macros",
|
||||
] }
|
||||
salsa-macros = "0.23.0"
|
||||
# salsa-macros = "0.23.0"
|
||||
salsa-macros = { git = "https://github.com/salsa-rs/salsa.git", rev = "e257df12eabd566825ba53bb12d782560b9a4dcd" }
|
||||
semver = "1.0.26"
|
||||
serde = { version = "1.0.219" }
|
||||
serde_derive = { version = "1.0.219" }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! Database used for testing `hir_def`.
|
||||
|
||||
use salsa::database::AsDynDatabase;
|
||||
use std::{fmt, panic, sync::Mutex};
|
||||
|
||||
use base_db::{
|
||||
|
|
@ -7,7 +8,7 @@ use base_db::{
|
|||
SourceDatabase, SourceRoot, SourceRootId, SourceRootInput,
|
||||
};
|
||||
use hir_expand::{InFile, files::FilePosition};
|
||||
use salsa::{AsDynDatabase, Durability};
|
||||
use salsa::{Durability, database::AsDynDatabase};
|
||||
use span::FileId;
|
||||
use syntax::{AstNode, algo, ast};
|
||||
use triomphe::Arc;
|
||||
|
|
|
|||
|
|
@ -286,9 +286,7 @@ impl<'db> DbInterner<'db> {
|
|||
// FIXME(next-solver): remove this method
|
||||
pub fn conjure() -> DbInterner<'db> {
|
||||
salsa::with_attached_database(|db| DbInterner {
|
||||
db: unsafe {
|
||||
std::mem::transmute::<&dyn HirDatabase, &'db dyn HirDatabase>(db.as_view())
|
||||
},
|
||||
db: unsafe { std::mem::transmute::<&dyn salsa::Database, &'db dyn HirDatabase>(db) },
|
||||
krate: None,
|
||||
block: None,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -62,9 +62,12 @@ impl<'db> IrPrint<ty::TraitRef<Self>> for DbInterner<'db> {
|
|||
let self_ty = &t.args.as_slice()[0];
|
||||
let trait_args = &t.args.as_slice()[1..];
|
||||
if trait_args.is_empty() {
|
||||
let db = db.zalsa().views().downcaster_for::<dyn HirDatabase>();
|
||||
db.downcast_unchecked(db)
|
||||
fmt.write_str(&format!(
|
||||
"{:?}: {}",
|
||||
self_ty,
|
||||
db.as_dyn_database().as_dyn_database(),
|
||||
db.as_view::<dyn HirDatabase>().trait_signature(trait_).name.as_str()
|
||||
))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -327,7 +327,8 @@ impl ToTokens for Lookup {
|
|||
let wrapper_struct = self.interned_struct_path.to_token_stream();
|
||||
let method = quote! {
|
||||
#sig {
|
||||
#wrapper_struct::ingredient(self).data(self.as_dyn_database(), id.as_id()).0.clone()
|
||||
let zalsa = self.zalsa();
|
||||
#wrapper_struct::ingredient(zalsa).data(zalsa, id.as_id()).0.clone()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -98,21 +98,38 @@ const _: () = {
|
|||
salsa::plumbing::Location { file: file!(), line: line!() };
|
||||
const DEBUG_NAME: &'static str = "SyntaxContextData";
|
||||
const REVISIONS: std::num::NonZeroUsize = std::num::NonZeroUsize::MAX;
|
||||
const PERSIST: bool = false;
|
||||
|
||||
type Fields<'a> = SyntaxContextData;
|
||||
type Struct<'a> = SyntaxContext;
|
||||
}
|
||||
impl SyntaxContext {
|
||||
pub fn ingredient<Db>(db: &Db) -> &zalsa_struct_::IngredientImpl<Self>
|
||||
|
||||
fn serialize<S>(_: &Self::Fields<'_>, _: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
Db: ?Sized + zalsa_::Database,
|
||||
S: zalsa_::serde::Serializer,
|
||||
{
|
||||
unimplemented!("attempted to serialize value that set `PERSIST` to false")
|
||||
}
|
||||
|
||||
fn deserialize<'de, D>(_: D) -> Result<Self::Fields<'static>, D::Error>
|
||||
where
|
||||
D: zalsa_::serde::Deserializer<'de>,
|
||||
{
|
||||
unimplemented!("attempted to deserialize value that cannot set `PERSIST` to false");
|
||||
}
|
||||
}
|
||||
|
||||
impl SyntaxContext {
|
||||
pub fn ingredient(zalsa: &zalsa_::Zalsa) -> &zalsa_struct_::IngredientImpl<Self> {
|
||||
static CACHE: zalsa_::IngredientCache<zalsa_struct_::IngredientImpl<SyntaxContext>> =
|
||||
zalsa_::IngredientCache::new();
|
||||
CACHE.get_or_create(db.zalsa(), || {
|
||||
db.zalsa()
|
||||
.lookup_jar_by_type::<zalsa_struct_::JarImpl<SyntaxContext>>()
|
||||
.get_or_create()
|
||||
})
|
||||
|
||||
// SAFETY: `lookup_jar_by_type` returns a valid ingredient index, and the only
|
||||
// ingredient created by our jar is the struct ingredient.
|
||||
unsafe {
|
||||
CACHE.get_or_create(zalsa, || {
|
||||
zalsa.lookup_jar_by_type::<zalsa_struct_::JarImpl<SyntaxContext>>()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
impl zalsa_::AsId for SyntaxContext {
|
||||
|
|
@ -132,13 +149,14 @@ const _: () = {
|
|||
impl zalsa_::SalsaStructInDb for SyntaxContext {
|
||||
type MemoIngredientMap = salsa::plumbing::MemoIngredientSingletonIndex;
|
||||
|
||||
fn lookup_or_create_ingredient_index(
|
||||
zalsa: &salsa::plumbing::Zalsa,
|
||||
) -> salsa::plumbing::IngredientIndices {
|
||||
zalsa
|
||||
.lookup_jar_by_type::<zalsa_struct_::JarImpl<SyntaxContext>>()
|
||||
.get_or_create()
|
||||
.into()
|
||||
fn lookup_ingredient_index(aux: &zalsa_::Zalsa) -> salsa::plumbing::IngredientIndices {
|
||||
aux.lookup_jar_by_type::<zalsa_struct_::JarImpl<SyntaxContext>>().into()
|
||||
}
|
||||
|
||||
fn entries(zalsa: &zalsa_::Zalsa) -> impl Iterator<Item = zalsa_::DatabaseKeyIndex> + '_ {
|
||||
let _ingredient_index =
|
||||
zalsa.lookup_jar_by_type::<zalsa_struct_::JarImpl<SyntaxContext>>();
|
||||
<SyntaxContext>::ingredient(zalsa).entries(zalsa).map(|entry| entry.key())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -149,6 +167,18 @@ const _: () = {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn memo_table(
|
||||
zalsa: &zalsa_::Zalsa,
|
||||
id: zalsa_::Id,
|
||||
current_revision: zalsa_::Revision,
|
||||
) -> zalsa_::MemoTableWithTypes<'_> {
|
||||
// SAFETY: Guaranteed by caller.
|
||||
unsafe {
|
||||
zalsa.table().memos::<zalsa_struct_::Value<SyntaxContext>>(id, current_revision)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl salsa::plumbing::Update for SyntaxContext {
|
||||
|
|
@ -184,8 +214,11 @@ const _: () = {
|
|||
Edition: zalsa_::interned::HashEqLike<T2>,
|
||||
SyntaxContext: zalsa_::interned::HashEqLike<T3>,
|
||||
{
|
||||
SyntaxContext::ingredient(db).intern(
|
||||
db.as_dyn_database(),
|
||||
let (zalsa, zalsa_local) = db.zalsas();
|
||||
|
||||
SyntaxContext::ingredient(zalsa).intern(
|
||||
zalsa,
|
||||
zalsa_local,
|
||||
StructKey::<'db>(
|
||||
outer_expn,
|
||||
outer_transparency,
|
||||
|
|
@ -216,7 +249,8 @@ const _: () = {
|
|||
Db: ?Sized + zalsa_::Database,
|
||||
{
|
||||
let id = self.as_salsa_id()?;
|
||||
let fields = SyntaxContext::ingredient(db).data(db.as_dyn_database(), id);
|
||||
let zalsa = db.zalsa();
|
||||
let fields = SyntaxContext::ingredient(zalsa).data(zalsa, id);
|
||||
fields.outer_expn
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +259,8 @@ const _: () = {
|
|||
Db: ?Sized + zalsa_::Database,
|
||||
{
|
||||
let Some(id) = self.as_salsa_id() else { return Transparency::Opaque };
|
||||
let fields = SyntaxContext::ingredient(db).data(db.as_dyn_database(), id);
|
||||
let zalsa = db.zalsa();
|
||||
let fields = SyntaxContext::ingredient(zalsa).data(zalsa, id);
|
||||
fields.outer_transparency
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +270,8 @@ const _: () = {
|
|||
{
|
||||
match self.as_salsa_id() {
|
||||
Some(id) => {
|
||||
let fields = SyntaxContext::ingredient(db).data(db.as_dyn_database(), id);
|
||||
let zalsa = db.zalsa();
|
||||
let fields = SyntaxContext::ingredient(zalsa).data(zalsa, id);
|
||||
fields.edition
|
||||
}
|
||||
None => Edition::from_u32(SyntaxContext::MAX_ID - self.into_u32()),
|
||||
|
|
@ -248,7 +284,8 @@ const _: () = {
|
|||
{
|
||||
match self.as_salsa_id() {
|
||||
Some(id) => {
|
||||
let fields = SyntaxContext::ingredient(db).data(db.as_dyn_database(), id);
|
||||
let zalsa = db.zalsa();
|
||||
let fields = SyntaxContext::ingredient(zalsa).data(zalsa, id);
|
||||
fields.parent
|
||||
}
|
||||
None => self,
|
||||
|
|
@ -262,7 +299,8 @@ const _: () = {
|
|||
{
|
||||
match self.as_salsa_id() {
|
||||
Some(id) => {
|
||||
let fields = SyntaxContext::ingredient(db).data(db.as_dyn_database(), id);
|
||||
let zalsa = db.zalsa();
|
||||
let fields = SyntaxContext::ingredient(zalsa).data(zalsa, id);
|
||||
fields.opaque
|
||||
}
|
||||
None => self,
|
||||
|
|
@ -276,7 +314,8 @@ const _: () = {
|
|||
{
|
||||
match self.as_salsa_id() {
|
||||
Some(id) => {
|
||||
let fields = SyntaxContext::ingredient(db).data(db.as_dyn_database(), id);
|
||||
let zalsa = db.zalsa();
|
||||
let fields = SyntaxContext::ingredient(zalsa).data(zalsa, id);
|
||||
fields.opaque_and_semitransparent
|
||||
}
|
||||
None => self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue