salsa/tests/compile-fail/span-tracked-getter.rs
2024-06-18 09:40:21 +02:00

30 lines
492 B
Rust

#[salsa::jar(db = Db)]
pub struct Jar(MyTracked<'_>, my_fn);
pub trait Db: salsa::DbWithJar<Jar> {}
#[salsa::db(Jar)]
#[derive(Default)]
struct Database {
storage: salsa::Storage<Self>,
}
impl salsa::Database for Database {}
impl Db for Database {}
#[salsa::tracked]
pub struct MyTracked<'db> {
field: u32,
}
#[salsa::tracked]
fn my_fn(db: &dyn crate::Db) {
let x = MyTracked::new(db, 22);
x.field(22);
}
fn main() {
let db = Database::default();
my_fn(&db);
}