mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-15 17:49:46 +00:00
389aa66bcf
In a previous PR we added the `include_all_fields` parameter to `DebugWithDb` to allow it to not create spurious dependencies. This PR takes a different approach: we simply ignore the dependencies created during debug operations. This is risky as it can create incorrect dependencies, but it is way more convenient and seems like what users probably want. It also means that `DebugWithDb` has a simpler signature that matches the `Debug` trait again, which seems good to me.
50 lines
939 B
Rust
50 lines
939 B
Rust
#![allow(warnings)]
|
|
|
|
use expect_test::expect;
|
|
use salsa::DebugWithDb;
|
|
|
|
#[salsa::jar(db = Db)]
|
|
struct Jar(MyInput);
|
|
|
|
trait Db: salsa::DbWithJar<Jar> {}
|
|
|
|
#[derive(Clone, Debug)]
|
|
struct Field {}
|
|
|
|
#[salsa::input(jar = Jar)]
|
|
struct MyInput {
|
|
#[id]
|
|
id_one: u32,
|
|
#[id]
|
|
id_two: u16,
|
|
|
|
field: Field,
|
|
}
|
|
|
|
#[salsa::db(Jar)]
|
|
#[derive(Default)]
|
|
struct Database {
|
|
storage: salsa::Storage<Self>,
|
|
}
|
|
|
|
impl salsa::Database for Database {}
|
|
|
|
impl Db for Database {}
|
|
|
|
#[test]
|
|
fn test_debug() {
|
|
let mut db = Database::default();
|
|
|
|
let input = MyInput::new(&mut db, 50, 10, Field {});
|
|
|
|
let actual = format!("{:?}", input.debug(&db));
|
|
let expected = expect!["MyInput { [salsa id]: 0, id_one: 50, id_two: 10, field: Field }"];
|
|
expected.assert_eq(&actual);
|
|
}
|
|
|
|
#[test]
|
|
fn test_set() {
|
|
let mut db = Database::default();
|
|
let input = MyInput::new(&mut db, 50, 10, Field {});
|
|
input.set_field(&mut db).to(Field {});
|
|
}
|