Unnamed repository; edit this file 'description' to name the repository.
Remove dev-dependency insta
Lukas Wirth 2024-02-07
parent def5a1d · commit e339c65
-rw-r--r--Cargo.lock145
-rw-r--r--crates/salsa/Cargo.toml3
-rw-r--r--crates/salsa/salsa-macros/src/database_storage.rs7
-rw-r--r--crates/salsa/salsa-macros/src/parenthesized.rs1
-rw-r--r--crates/salsa/salsa-macros/src/query_group.rs36
-rw-r--r--crates/salsa/src/derived.rs1
-rw-r--r--crates/salsa/src/derived/slot.rs1
-rw-r--r--crates/salsa/src/doctest.rs1
-rw-r--r--crates/salsa/src/durability.rs1
-rw-r--r--crates/salsa/src/hash.rs1
-rw-r--r--crates/salsa/src/input.rs1
-rw-r--r--crates/salsa/src/intern_id.rs1
-rw-r--r--crates/salsa/src/interned.rs1
-rw-r--r--crates/salsa/src/lib.rs1
-rw-r--r--crates/salsa/src/lru.rs1
-rw-r--r--crates/salsa/src/plumbing.rs1
-rw-r--r--crates/salsa/src/revision.rs1
-rw-r--r--crates/salsa/src/runtime.rs1
-rw-r--r--crates/salsa/src/runtime/dependency_graph.rs1
-rw-r--r--crates/salsa/src/runtime/local_state.rs1
-rw-r--r--crates/salsa/src/storage.rs1
-rw-r--r--crates/salsa/tests/cycles.rs214
-rw-r--r--crates/salsa/tests/on_demand_inputs.rs62
-rw-r--r--crates/salsa/tests/parallel/parallel_cycle_none_recover.rs14
24 files changed, 188 insertions, 310 deletions
diff --git a/Cargo.lock b/Cargo.lock
index aebff14048..4be85b1bc1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -222,18 +222,6 @@ dependencies = [
]
[[package]]
-name = "console"
-version = "0.15.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb"
-dependencies = [
- "encode_unicode",
- "lazy_static",
- "libc",
- "windows-sys 0.52.0",
-]
-
-[[package]]
name = "countme"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -376,12 +364,6 @@ dependencies = [
]
[[package]]
-name = "encode_unicode"
-version = "0.3.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
-
-[[package]]
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -848,19 +830,6 @@ dependencies = [
]
[[package]]
-name = "insta"
-version = "1.34.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc"
-dependencies = [
- "console",
- "lazy_static",
- "linked-hash-map",
- "similar",
- "yaml-rust",
-]
-
-[[package]]
name = "intern"
version = "0.0.0"
dependencies = [
@@ -944,12 +913,6 @@ dependencies = [
]
[[package]]
-name = "libm"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
-
-[[package]]
name = "libmimalloc-sys"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1205,16 +1168,6 @@ dependencies = [
]
[[package]]
-name = "num-traits"
-version = "0.2.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
-dependencies = [
- "autocfg",
- "libm",
-]
-
-[[package]]
name = "num_cpus"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1274,7 +1227,7 @@ dependencies = [
"libc",
"redox_syscall 0.4.1",
"smallvec",
- "windows-targets 0.48.0",
+ "windows-targets",
]
[[package]]
@@ -1620,16 +1573,6 @@ dependencies = [
]
[[package]]
-name = "rand_distr"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31"
-dependencies = [
- "num-traits",
- "rand",
-]
-
-[[package]]
name = "rayon"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1769,14 +1712,13 @@ name = "salsa"
version = "0.0.0"
dependencies = [
"diff",
+ "expect-test",
"indexmap",
- "insta",
"linked-hash-map",
"lock_api",
"oorandom",
"parking_lot",
"rand",
- "rand_distr",
"rustc-hash",
"salsa-macros",
"smallvec",
@@ -1887,12 +1829,6 @@ dependencies = [
]
[[package]]
-name = "similar"
-version = "2.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21"
-
-[[package]]
name = "smallvec"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2426,16 +2362,7 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
- "windows-targets 0.48.0",
-]
-
-[[package]]
-name = "windows-sys"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
-dependencies = [
- "windows-targets 0.52.0",
+ "windows-targets",
]
[[package]]
@@ -2454,21 +2381,6 @@ dependencies = [
]
[[package]]
-name = "windows-targets"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
-dependencies = [
- "windows_aarch64_gnullvm 0.52.0",
- "windows_aarch64_msvc 0.52.0",
- "windows_i686_gnu 0.52.0",
- "windows_i686_msvc 0.52.0",
- "windows_x86_64_gnu 0.52.0",
- "windows_x86_64_gnullvm 0.52.0",
- "windows_x86_64_msvc 0.52.0",
-]
-
-[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2481,12 +2393,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]]
-name = "windows_aarch64_gnullvm"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
-
-[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2499,12 +2405,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]]
-name = "windows_aarch64_msvc"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
-
-[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2517,12 +2417,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]]
-name = "windows_i686_gnu"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
-
-[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2535,12 +2429,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]]
-name = "windows_i686_msvc"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
-
-[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2553,12 +2441,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]]
-name = "windows_x86_64_gnu"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
-
-[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2571,12 +2453,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]]
-name = "windows_x86_64_gnullvm"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
-
-[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2589,12 +2465,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
-name = "windows_x86_64_msvc"
-version = "0.52.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
-
-[[package]]
name = "write-json"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2644,15 +2514,6 @@ dependencies = [
]
[[package]]
-name = "yaml-rust"
-version = "0.4.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
-dependencies = [
- "linked-hash-map",
-]
-
-[[package]]
name = "zip"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/crates/salsa/Cargo.toml b/crates/salsa/Cargo.toml
index a2c08b1252..42885b47a6 100644
--- a/crates/salsa/Cargo.toml
+++ b/crates/salsa/Cargo.toml
@@ -28,6 +28,5 @@ salsa-macros = { version = "0.0.0", path = "salsa-macros" }
diff = "0.1.13"
linked-hash-map = "0.5.6"
rand = "0.8.5"
-rand_distr = "0.4.3"
test-log = "0.2.14"
-insta = "1.18.0"
+expect-test = "1.4.0"
diff --git a/crates/salsa/salsa-macros/src/database_storage.rs b/crates/salsa/salsa-macros/src/database_storage.rs
index 52d424c5f8..26b8e61309 100644
--- a/crates/salsa/salsa-macros/src/database_storage.rs
+++ b/crates/salsa/salsa-macros/src/database_storage.rs
@@ -1,3 +1,4 @@
+//!
use heck::ToSnakeCase;
use proc_macro::TokenStream;
use syn::parse::{Parse, ParseStream};
@@ -113,10 +114,8 @@ pub(crate) fn database(args: TokenStream, input: TokenStream) -> TokenStream {
let mut maybe_changed_ops = proc_macro2::TokenStream::new();
let mut cycle_recovery_strategy_ops = proc_macro2::TokenStream::new();
let mut for_each_ops = proc_macro2::TokenStream::new();
- for ((QueryGroup { group_path }, group_storage), group_index) in query_groups
- .iter()
- .zip(&query_group_storage_names)
- .zip(0_u16..)
+ for ((QueryGroup { group_path }, group_storage), group_index) in
+ query_groups.iter().zip(&query_group_storage_names).zip(0_u16..)
{
fmt_ops.extend(quote! {
#group_index => {
diff --git a/crates/salsa/salsa-macros/src/parenthesized.rs b/crates/salsa/salsa-macros/src/parenthesized.rs
index b755879f19..d61166cecd 100644
--- a/crates/salsa/salsa-macros/src/parenthesized.rs
+++ b/crates/salsa/salsa-macros/src/parenthesized.rs
@@ -1,3 +1,4 @@
+//!
pub(crate) struct Parenthesized<T>(pub(crate) T);
impl<T> syn::parse::Parse for Parenthesized<T>
diff --git a/crates/salsa/salsa-macros/src/query_group.rs b/crates/salsa/salsa-macros/src/query_group.rs
index 5cb6624501..0b1ee2d3b5 100644
--- a/crates/salsa/salsa-macros/src/query_group.rs
+++ b/crates/salsa/salsa-macros/src/query_group.rs
@@ -1,3 +1,4 @@
+//!
use std::{convert::TryFrom, iter::FromIterator};
use crate::parenthesized::Parenthesized;
@@ -20,12 +21,9 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
let input_span = input.span();
let (trait_attrs, salsa_attrs) = filter_attrs(input.attrs);
if !salsa_attrs.is_empty() {
- return Error::new(
- input_span,
- format!("unsupported attributes: {:?}", salsa_attrs),
- )
- .to_compile_error()
- .into();
+ return Error::new(input_span, format!("unsupported attributes: {:?}", salsa_attrs))
+ .to_compile_error()
+ .into();
}
let trait_vis = input.vis;
@@ -43,7 +41,8 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
let mut cycle = None;
let mut invoke = None;
- let mut query_type = format_ident!("{}Query", query_name.to_string().to_upper_camel_case());
+ let mut query_type =
+ format_ident!("{}Query", query_name.to_string().to_upper_camel_case());
let mut num_storages = 0;
// Extract attributes.
@@ -175,9 +174,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
fn_name: lookup_fn_name,
receiver: self_receiver.clone(),
attrs: vec![], // FIXME -- some automatically generated docs on this method?
- storage: QueryStorage::InternedLookup {
- intern_query_type: query_type.clone(),
- },
+ storage: QueryStorage::InternedLookup { intern_query_type: query_type.clone() },
keys: lookup_keys,
value: lookup_value,
invoke: None,
@@ -211,9 +208,9 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
let mut storage_fields = proc_macro2::TokenStream::new();
let mut queries_with_storage = vec![];
for query in &queries {
- #[allow(clippy::map_identity)] // clippy is incorrect here, this is not the identity function due to match ergonomics
- let (key_names, keys): (Vec<_>, Vec<_>) =
- query.keys.iter().map(|(a, b)| (a, b)).unzip();
+ #[allow(clippy::map_identity)]
+ // clippy is incorrect here, this is not the identity function due to match ergonomics
+ let (key_names, keys): (Vec<_>, Vec<_>) = query.keys.iter().map(|(a, b)| (a, b)).unzip();
let value = &query.value;
let fn_name = &query.fn_name;
let qt = &query.query_type;
@@ -361,11 +358,8 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
}
});
- let non_transparent_queries = || {
- queries
- .iter()
- .filter(|q| !matches!(q.storage, QueryStorage::Transparent))
- };
+ let non_transparent_queries =
+ || queries.iter().filter(|q| !matches!(q.storage, QueryStorage::Transparent));
// Emit the query types.
for (query, query_index) in non_transparent_queries().zip(0_u16..) {
@@ -681,11 +675,7 @@ impl TryFrom<syn::Attribute> for SalsaAttr {
}
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 != "salsa").unwrap_or(true) || path.segments.len() != 2
}
fn filter_attrs(attrs: Vec<Attribute>) -> (Vec<Attribute>, Vec<SalsaAttr>) {
diff --git a/crates/salsa/src/derived.rs b/crates/salsa/src/derived.rs
index 404e10e196..c381e66e08 100644
--- a/crates/salsa/src/derived.rs
+++ b/crates/salsa/src/derived.rs
@@ -1,3 +1,4 @@
+//!
use crate::debug::TableEntry;
use crate::durability::Durability;
use crate::hash::FxIndexMap;
diff --git a/crates/salsa/src/derived/slot.rs b/crates/salsa/src/derived/slot.rs
index 957d628984..4fad791a26 100644
--- a/crates/salsa/src/derived/slot.rs
+++ b/crates/salsa/src/derived/slot.rs
@@ -1,3 +1,4 @@
+//!
use crate::debug::TableEntry;
use crate::derived::MemoizationPolicy;
use crate::durability::Durability;
diff --git a/crates/salsa/src/doctest.rs b/crates/salsa/src/doctest.rs
index 7bafff0d00..29a8066356 100644
--- a/crates/salsa/src/doctest.rs
+++ b/crates/salsa/src/doctest.rs
@@ -1,3 +1,4 @@
+//!
#![allow(dead_code)]
/// Test that a database with a key/value that is not `Send` will,
diff --git a/crates/salsa/src/durability.rs b/crates/salsa/src/durability.rs
index 58a81e3786..0c82f6345a 100644
--- a/crates/salsa/src/durability.rs
+++ b/crates/salsa/src/durability.rs
@@ -1,3 +1,4 @@
+//!
/// Describes how likely a value is to change -- how "durable" it is.
/// By default, inputs have `Durability::LOW` and interned values have
/// `Durability::HIGH`. But inputs can be explicitly set with other
diff --git a/crates/salsa/src/hash.rs b/crates/salsa/src/hash.rs
index 3b2d7df3fb..47a2dd1ce0 100644
--- a/crates/salsa/src/hash.rs
+++ b/crates/salsa/src/hash.rs
@@ -1,3 +1,4 @@
+//!
pub(crate) type FxHasher = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
pub(crate) type FxIndexSet<K> = indexmap::IndexSet<K, FxHasher>;
pub(crate) type FxIndexMap<K, V> = indexmap::IndexMap<K, V, FxHasher>;
diff --git a/crates/salsa/src/input.rs b/crates/salsa/src/input.rs
index 037e45b908..f6188d4a84 100644
--- a/crates/salsa/src/input.rs
+++ b/crates/salsa/src/input.rs
@@ -1,3 +1,4 @@
+//!
use crate::debug::TableEntry;
use crate::durability::Durability;
use crate::hash::FxIndexMap;
diff --git a/crates/salsa/src/intern_id.rs b/crates/salsa/src/intern_id.rs
index b060d8aab6..a7bbc088f9 100644
--- a/crates/salsa/src/intern_id.rs
+++ b/crates/salsa/src/intern_id.rs
@@ -1,3 +1,4 @@
+//!
use std::fmt;
use std::num::NonZeroU32;
diff --git a/crates/salsa/src/interned.rs b/crates/salsa/src/interned.rs
index 392534ea0b..22f22e6112 100644
--- a/crates/salsa/src/interned.rs
+++ b/crates/salsa/src/interned.rs
@@ -1,3 +1,4 @@
+//!
use crate::debug::TableEntry;
use crate::durability::Durability;
use crate::intern_id::InternId;
diff --git a/crates/salsa/src/lib.rs b/crates/salsa/src/lib.rs
index 19a9fd2571..575408f362 100644
--- a/crates/salsa/src/lib.rs
+++ b/crates/salsa/src/lib.rs
@@ -1,3 +1,4 @@
+//!
#![allow(clippy::type_complexity)]
#![allow(clippy::question_mark)]
#![warn(rust_2018_idioms)]
diff --git a/crates/salsa/src/lru.rs b/crates/salsa/src/lru.rs
index 18441ea004..c6b9778f20 100644
--- a/crates/salsa/src/lru.rs
+++ b/crates/salsa/src/lru.rs
@@ -1,3 +1,4 @@
+//!
use oorandom::Rand64;
use parking_lot::Mutex;
use std::fmt::Debug;
diff --git a/crates/salsa/src/plumbing.rs b/crates/salsa/src/plumbing.rs
index f09d6d7337..560a9b8315 100644
--- a/crates/salsa/src/plumbing.rs
+++ b/crates/salsa/src/plumbing.rs
@@ -1,3 +1,4 @@
+//!
#![allow(missing_docs)]
use crate::debug::TableEntry;
diff --git a/crates/salsa/src/revision.rs b/crates/salsa/src/revision.rs
index 61d38a3bcc..d97aaf9deb 100644
--- a/crates/salsa/src/revision.rs
+++ b/crates/salsa/src/revision.rs
@@ -1,3 +1,4 @@
+//!
use std::num::NonZeroU32;
use std::sync::atomic::{AtomicU32, Ordering};
diff --git a/crates/salsa/src/runtime.rs b/crates/salsa/src/runtime.rs
index 29c5afa37a..40b8856991 100644
--- a/crates/salsa/src/runtime.rs
+++ b/crates/salsa/src/runtime.rs
@@ -1,3 +1,4 @@
+//!
use crate::durability::Durability;
use crate::hash::FxIndexSet;
use crate::plumbing::CycleRecoveryStrategy;
diff --git a/crates/salsa/src/runtime/dependency_graph.rs b/crates/salsa/src/runtime/dependency_graph.rs
index 9fa2851d0e..e41eb280de 100644
--- a/crates/salsa/src/runtime/dependency_graph.rs
+++ b/crates/salsa/src/runtime/dependency_graph.rs
@@ -1,3 +1,4 @@
+//!
use triomphe::Arc;
use crate::{DatabaseKeyIndex, RuntimeId};
diff --git a/crates/salsa/src/runtime/local_state.rs b/crates/salsa/src/runtime/local_state.rs
index b21f1ee4af..91b95dffe7 100644
--- a/crates/salsa/src/runtime/local_state.rs
+++ b/crates/salsa/src/runtime/local_state.rs
@@ -1,3 +1,4 @@
+//!
use tracing::debug;
use crate::durability::Durability;
diff --git a/crates/salsa/src/storage.rs b/crates/salsa/src/storage.rs
index e0acf44041..c0e6416f4a 100644
--- a/crates/salsa/src/storage.rs
+++ b/crates/salsa/src/storage.rs
@@ -1,3 +1,4 @@
+//!
use crate::{plumbing::DatabaseStorageTypes, Runtime};
use triomphe::Arc;
diff --git a/crates/salsa/tests/cycles.rs b/crates/salsa/tests/cycles.rs
index 4c3ec312f2..0f89c6375f 100644
--- a/crates/salsa/tests/cycles.rs
+++ b/crates/salsa/tests/cycles.rs
@@ -1,5 +1,6 @@
use std::panic::UnwindSafe;
+use expect_test::expect;
use salsa::{Durability, ParallelDatabase, Snapshot};
use test_log::test;
@@ -179,24 +180,26 @@ fn extract_cycle(f: impl FnOnce() + UnwindSafe) -> salsa::Cycle {
fn cycle_memoized() {
let db = DatabaseImpl::default();
let cycle = extract_cycle(|| db.memoized_a());
- insta::assert_debug_snapshot!(cycle.unexpected_participants(&db), @r###"
- [
- "memoized_a(())",
- "memoized_b(())",
- ]
- "###);
+ expect![[r#"
+ [
+ "memoized_a(())",
+ "memoized_b(())",
+ ]
+ "#]]
+ .assert_debug_eq(&cycle.unexpected_participants(&db));
}
#[test]
fn cycle_volatile() {
let db = DatabaseImpl::default();
let cycle = extract_cycle(|| db.volatile_a());
- insta::assert_debug_snapshot!(cycle.unexpected_participants(&db), @r###"
- [
- "volatile_a(())",
- "volatile_b(())",
- ]
- "###);
+ expect![[r#"
+ [
+ "volatile_a(())",
+ "volatile_b(())",
+ ]
+ "#]]
+ .assert_debug_eq(&cycle.unexpected_participants(&db));
}
#[test]
@@ -228,12 +231,13 @@ fn inner_cycle() {
let err = query.cycle_c();
assert!(err.is_err());
let cycle = err.unwrap_err().cycle;
- insta::assert_debug_snapshot!(cycle, @r###"
- [
- "cycle_a(())",
- "cycle_b(())",
- ]
- "###);
+ expect![[r#"
+ [
+ "cycle_a(())",
+ "cycle_b(())",
+ ]
+ "#]]
+ .assert_debug_eq(&cycle);
}
#[test]
@@ -265,16 +269,17 @@ fn cycle_revalidate_unchanged_twice() {
db.set_c_invokes(CycleQuery::A); // force new revisi5on
// on this run
- insta::assert_debug_snapshot!(db.cycle_a(), @r###"
- Err(
- Error {
- cycle: [
- "cycle_a(())",
- "cycle_b(())",
- ],
- },
- )
- "###);
+ expect![[r#"
+ Err(
+ Error {
+ cycle: [
+ "cycle_a(())",
+ "cycle_b(())",
+ ],
+ },
+ )
+ "#]]
+ .assert_debug_eq(&db.cycle_a());
}
#[test]
@@ -346,16 +351,17 @@ fn cycle_mixed_1() {
db.set_c_invokes(CycleQuery::B);
let u = db.cycle_c();
- insta::assert_debug_snapshot!(u, @r###"
- Err(
- Error {
- cycle: [
- "cycle_b(())",
- "cycle_c(())",
- ],
- },
- )
- "###);
+ expect![[r#"
+ Err(
+ Error {
+ cycle: [
+ "cycle_b(())",
+ "cycle_c(())",
+ ],
+ },
+ )
+ "#]]
+ .assert_debug_eq(&u);
}
#[test]
@@ -372,17 +378,18 @@ fn cycle_mixed_2() {
db.set_c_invokes(CycleQuery::A);
let u = db.cycle_a();
- insta::assert_debug_snapshot!(u, @r###"
- Err(
- Error {
- cycle: [
- "cycle_a(())",
- "cycle_b(())",
- "cycle_c(())",
- ],
- },
- )
- "###);
+ expect![[r#"
+ Err(
+ Error {
+ cycle: [
+ "cycle_a(())",
+ "cycle_b(())",
+ "cycle_c(())",
+ ],
+ },
+ )
+ "#]]
+ .assert_debug_eq(&u);
}
#[test]
@@ -399,26 +406,27 @@ fn cycle_deterministic_order() {
};
let a = db().cycle_a();
let b = db().cycle_b();
- insta::assert_debug_snapshot!((a, b), @r###"
- (
- Err(
- Error {
- cycle: [
- "cycle_a(())",
- "cycle_b(())",
- ],
- },
- ),
- Err(
- Error {
- cycle: [
- "cycle_a(())",
- "cycle_b(())",
- ],
- },
- ),
- )
- "###);
+ expect![[r#"
+ (
+ Err(
+ Error {
+ cycle: [
+ "cycle_a(())",
+ "cycle_b(())",
+ ],
+ },
+ ),
+ Err(
+ Error {
+ cycle: [
+ "cycle_a(())",
+ "cycle_b(())",
+ ],
+ },
+ ),
+ )
+ "#]]
+ .assert_debug_eq(&(a, b));
}
#[test]
@@ -443,34 +451,35 @@ fn cycle_multiple() {
let c = db.cycle_c();
let b = db.cycle_b();
let a = db.cycle_a();
- insta::assert_debug_snapshot!((a, b, c), @r###"
- (
- Err(
- Error {
- cycle: [
- "cycle_a(())",
- "cycle_b(())",
- ],
- },
- ),
- Err(
- Error {
- cycle: [
- "cycle_a(())",
- "cycle_b(())",
- ],
- },
- ),
- Err(
- Error {
- cycle: [
- "cycle_a(())",
- "cycle_b(())",
- ],
- },
- ),
- )
- "###);
+ expect![[r#"
+ (
+ Err(
+ Error {
+ cycle: [
+ "cycle_a(())",
+ "cycle_b(())",
+ ],
+ },
+ ),
+ Err(
+ Error {
+ cycle: [
+ "cycle_a(())",
+ "cycle_b(())",
+ ],
+ },
+ ),
+ Err(
+ Error {
+ cycle: [
+ "cycle_a(())",
+ "cycle_b(())",
+ ],
+ },
+ ),
+ )
+ "#]]
+ .assert_debug_eq(&(a, b, c));
}
#[test]
@@ -485,9 +494,10 @@ fn cycle_recovery_set_but_not_participating() {
// Here we expect C to panic and A not to recover:
let r = extract_cycle(|| drop(db.cycle_a()));
- insta::assert_debug_snapshot!(r.all_participants(&db), @r###"
- [
- "cycle_c(())",
- ]
- "###);
+ expect![[r#"
+ [
+ "cycle_c(())",
+ ]
+ "#]]
+ .assert_debug_eq(&r.all_participants(&db));
}
diff --git a/crates/salsa/tests/on_demand_inputs.rs b/crates/salsa/tests/on_demand_inputs.rs
index 2ad4975eff..61039ae7b2 100644
--- a/crates/salsa/tests/on_demand_inputs.rs
+++ b/crates/salsa/tests/on_demand_inputs.rs
@@ -100,16 +100,16 @@ fn on_demand_input_durability() {
db.external_state.insert(2, 20);
assert_eq!(db.b(1), 10);
assert_eq!(db.b(2), 20);
- insta::assert_debug_snapshot!(events, @r###"
- RefCell {
- value: [
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: b(1) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(1) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: b(2) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(2) } }",
- ],
- }
- "###);
+ expect_test::expect![[r#"
+ RefCell {
+ value: [
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: b(1) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(1) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: b(2) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(2) } }",
+ ],
+ }
+ "#]].assert_debug_eq(&events);
eprintln!("------------------");
db.salsa_runtime_mut().synthetic_write(Durability::LOW);
@@ -117,17 +117,17 @@ fn on_demand_input_durability() {
assert_eq!(db.c(1), 10);
assert_eq!(db.c(2), 20);
// Re-execute `a(2)` because that has low durability, but not `a(1)`
- insta::assert_debug_snapshot!(events, @r###"
- RefCell {
- value: [
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: c(1) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: b(1) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: c(2) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(2) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: b(2) } }",
- ],
- }
- "###);
+ expect_test::expect![[r#"
+ RefCell {
+ value: [
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: c(1) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: b(1) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: c(2) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(2) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: b(2) } }",
+ ],
+ }
+ "#]].assert_debug_eq(&events);
eprintln!("------------------");
db.salsa_runtime_mut().synthetic_write(Durability::HIGH);
@@ -136,14 +136,14 @@ fn on_demand_input_durability() {
assert_eq!(db.c(2), 20);
// Re-execute both `a(1)` and `a(2)`, but we don't re-execute any `b` queries as the
// result didn't actually change.
- insta::assert_debug_snapshot!(events, @r###"
- RefCell {
- value: [
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(1) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: c(1) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(2) } }",
- "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: c(2) } }",
- ],
- }
- "###);
+ expect_test::expect![[r#"
+ RefCell {
+ value: [
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(1) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: c(1) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: a(2) } }",
+ "Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: c(2) } }",
+ ],
+ }
+ "#]].assert_debug_eq(&events);
}
diff --git a/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs b/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs
index 1467041422..35fe379118 100644
--- a/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs
+++ b/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs
@@ -3,6 +3,7 @@
//! both intra and cross thread.
use crate::setup::{Knobs, ParDatabaseImpl};
+use expect_test::expect;
use salsa::ParallelDatabase;
use test_log::test;
@@ -25,12 +26,13 @@ fn parallel_cycle_none_recover() {
// Right now, it panics with a string.
let err_b = thread_b.join().unwrap_err();
if let Some(c) = err_b.downcast_ref::<salsa::Cycle>() {
- insta::assert_debug_snapshot!(c.unexpected_participants(&db), @r###"
- [
- "a(-1)",
- "b(-1)",
- ]
- "###);
+ expect![[r#"
+ [
+ "a(-1)",
+ "b(-1)",
+ ]
+ "#]]
+ .assert_debug_eq(&c.unexpected_participants(&db));
} else {
panic!("b failed in an unexpected way: {:?}", err_b);
}