This commit is contained in:
Lukas Wirth 2024-02-07 16:53:27 +01:00
parent 731b159f10
commit 3688064ff5
11 changed files with 17 additions and 44 deletions

View File

@ -30,3 +30,6 @@ rand = "0.8.5"
test-log = "0.2.14" test-log = "0.2.14"
expect-test = "1.4.0" expect-test = "1.4.0"
dissimilar = "1.0.7" dissimilar = "1.0.7"
[lints]
workspace = true

View File

@ -18,3 +18,6 @@ heck = "0.4"
proc-macro2 = "1.0" proc-macro2 = "1.0"
quote = "1.0" quote = "1.0"
syn = { version = "2.0", features = ["full", "extra-traits"] } syn = { version = "2.0", features = ["full", "extra-traits"] }
[lints]
workspace = true

View File

@ -203,12 +203,6 @@ pub(crate) fn database(args: TokenStream, input: TokenStream) -> TokenStream {
output.extend(has_group_impls); output.extend(has_group_impls);
if std::env::var("SALSA_DUMP").is_ok() {
println!("~~~ database_storage");
println!("{}", output);
println!("~~~ database_storage");
}
output.into() output.into()
} }
@ -218,7 +212,7 @@ struct QueryGroupList {
} }
impl Parse for QueryGroupList { impl Parse for QueryGroupList {
fn parse(input: ParseStream) -> syn::Result<Self> { fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let query_groups: PunctuatedQueryGroups = let query_groups: PunctuatedQueryGroups =
input.parse_terminated(QueryGroup::parse, Token![,])?; input.parse_terminated(QueryGroup::parse, Token![,])?;
Ok(QueryGroupList { query_groups }) Ok(QueryGroupList { query_groups })
@ -241,7 +235,7 @@ impl Parse for QueryGroup {
/// ```ignore /// ```ignore
/// impl HelloWorldDatabase; /// impl HelloWorldDatabase;
/// ``` /// ```
fn parse(input: ParseStream) -> syn::Result<Self> { fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
let group_path: Path = input.parse()?; let group_path: Path = input.parse()?;
Ok(QueryGroup { group_path }) Ok(QueryGroup { group_path })
} }
@ -250,7 +244,7 @@ impl Parse for QueryGroup {
struct Nothing; struct Nothing;
impl Parse for Nothing { impl Parse for Nothing {
fn parse(_input: ParseStream) -> syn::Result<Self> { fn parse(_input: ParseStream<'_>) -> syn::Result<Self> {
Ok(Nothing) Ok(Nothing)
} }
} }

View File

@ -2,8 +2,6 @@
#![recursion_limit = "256"] #![recursion_limit = "256"]
extern crate proc_macro;
extern crate proc_macro2;
#[macro_use] #[macro_use]
extern crate quote; extern crate quote;

View File

@ -5,7 +5,7 @@ impl<T> syn::parse::Parse for Parenthesized<T>
where where
T: syn::parse::Parse, T: syn::parse::Parse,
{ {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> { fn parse(input: syn::parse::ParseStream<'_>) -> syn::Result<Self> {
let content; let content;
syn::parenthesized!(content in input); syn::parenthesized!(content in input);
content.parse::<T>().map(Parenthesized) content.parse::<T>().map(Parenthesized)

View File

@ -625,13 +625,6 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
} }
// ANCHOR_END:group_storage_methods // ANCHOR_END:group_storage_methods
}); });
if std::env::var("SALSA_DUMP").is_ok() {
println!("~~~ query_group");
println!("{}", output);
println!("~~~ query_group");
}
output.into() output.into()
} }

View File

@ -51,6 +51,7 @@ struct Error {
} }
#[salsa::database(GroupStruct)] #[salsa::database(GroupStruct)]
#[derive(Default)]
struct DatabaseImpl { struct DatabaseImpl {
storage: salsa::Storage<Self>, storage: salsa::Storage<Self>,
} }
@ -63,14 +64,6 @@ impl ParallelDatabase for DatabaseImpl {
} }
} }
impl Default for DatabaseImpl {
fn default() -> Self {
let res = DatabaseImpl { storage: salsa::Storage::default() };
res
}
}
/// The queries A, B, and C in `Database` can be configured /// The queries A, B, and C in `Database` can be configured
/// to invoke one another in arbitrary ways using this /// to invoke one another in arbitrary ways using this
/// enum. /// enum.
@ -151,17 +144,14 @@ impl CycleQuery {
} }
fn cycle_a(db: &dyn Database) -> Result<(), Error> { fn cycle_a(db: &dyn Database) -> Result<(), Error> {
dbg!("cycle_a");
db.a_invokes().invoke(db) db.a_invokes().invoke(db)
} }
fn cycle_b(db: &dyn Database) -> Result<(), Error> { fn cycle_b(db: &dyn Database) -> Result<(), Error> {
dbg!("cycle_b");
db.b_invokes().invoke(db) db.b_invokes().invoke(db)
} }
fn cycle_c(db: &dyn Database) -> Result<(), Error> { fn cycle_c(db: &dyn Database) -> Result<(), Error> {
dbg!("cycle_c");
db.c_invokes().invoke(db) db.c_invokes().invoke(db)
} }

View File

@ -33,6 +33,7 @@ impl TestContextImpl {
return; return;
} }
#[allow(clippy::print_stdout)]
for diff in dissimilar::diff(expected_text, actual_text) { for diff in dissimilar::diff(expected_text, actual_text) {
match diff { match diff {
dissimilar::Chunk::Delete(l) => println!("-{}", l), dissimilar::Chunk::Delete(l) => println!("-{}", l),

View File

@ -1,5 +1,3 @@
extern crate salsa;
use std::rc::Rc; use std::rc::Rc;
#[salsa::query_group(NoSendSyncStorage)] #[salsa::query_group(NoSendSyncStorage)]

View File

@ -4,6 +4,8 @@
//! via a b query with zero inputs, which uses `add_synthetic_read` to //! via a b query with zero inputs, which uses `add_synthetic_read` to
//! tweak durability and `invalidate` to clear the input. //! tweak durability and `invalidate` to clear the input.
#![allow(clippy::disallowed_types, clippy::type_complexity)]
use std::{cell::RefCell, collections::HashMap, rc::Rc}; use std::{cell::RefCell, collections::HashMap, rc::Rc};
use salsa::{Database as _, Durability, EventKind}; use salsa::{Database as _, Durability, EventKind};
@ -40,8 +42,6 @@ struct Database {
impl salsa::Database for Database { impl salsa::Database for Database {
fn salsa_event(&self, event: salsa::Event) { fn salsa_event(&self, event: salsa::Event) {
dbg!(event.debug(self));
if let Some(cb) = &self.on_event { if let Some(cb) = &self.on_event {
cb(self, event) cb(self, event)
} }
@ -111,7 +111,6 @@ fn on_demand_input_durability() {
} }
"#]].assert_debug_eq(&events); "#]].assert_debug_eq(&events);
eprintln!("------------------");
db.salsa_runtime_mut().synthetic_write(Durability::LOW); db.salsa_runtime_mut().synthetic_write(Durability::LOW);
events.replace(vec![]); events.replace(vec![]);
assert_eq!(db.c(1), 10); assert_eq!(db.c(1), 10);
@ -129,7 +128,6 @@ fn on_demand_input_durability() {
} }
"#]].assert_debug_eq(&events); "#]].assert_debug_eq(&events);
eprintln!("------------------");
db.salsa_runtime_mut().synthetic_write(Durability::HIGH); db.salsa_runtime_mut().synthetic_write(Durability::HIGH);
events.replace(vec![]); events.replace(vec![]);
assert_eq!(db.c(1), 10); assert_eq!(db.c(1), 10);

View File

@ -46,7 +46,7 @@ impl<T> WithValue<T> for Cell<T> {
fn with_value<R>(&self, value: T, closure: impl FnOnce() -> R) -> R { fn with_value<R>(&self, value: T, closure: impl FnOnce() -> R) -> R {
let old_value = self.replace(value); let old_value = self.replace(value);
let result = catch_unwind(AssertUnwindSafe(|| closure())); let result = catch_unwind(AssertUnwindSafe(closure));
self.set(old_value); self.set(old_value);
@ -57,18 +57,13 @@ impl<T> WithValue<T> for Cell<T> {
} }
} }
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Default, Clone, Copy, PartialEq, Eq)]
pub(crate) enum CancellationFlag { pub(crate) enum CancellationFlag {
#[default]
Down, Down,
Panic, Panic,
} }
impl Default for CancellationFlag {
fn default() -> CancellationFlag {
CancellationFlag::Down
}
}
/// Various "knobs" that can be used to customize how the queries /// Various "knobs" that can be used to customize how the queries
/// behave on one specific thread. Note that this state is /// behave on one specific thread. Note that this state is
/// intentionally thread-local (apart from `signal`). /// intentionally thread-local (apart from `signal`).