salsa/tests/compile-fail/panic-when-reading-fields-of-tracked-structs-from-older-revisions.rs

25 lines
524 B
Rust
Raw Normal View History

2024-07-19 12:05:39 +00:00
use salsa::prelude::*;
2024-07-16 10:04:01 +00:00
#[salsa::input]
struct MyInput {
field: u32,
}
2024-07-16 10:04:01 +00:00
#[salsa::tracked]
2024-05-24 01:16:30 +00:00
struct MyTracked<'db> {
field: u32,
}
2024-07-16 10:04:01 +00:00
#[salsa::tracked]
2024-07-19 12:05:39 +00:00
fn tracked_fn<'db>(db: &'db dyn salsa::Database, input: MyInput) -> MyTracked<'db> {
MyTracked::new(db, input.field(db) / 2)
}
2024-07-19 12:05:39 +00:00
fn main() {
let mut db = salsa::default_database();
let input = MyInput::new(&db, 22);
let tracked = tracked_fn(&db, input);
input.set_field(&mut db).to(24);
2024-07-19 12:05:39 +00:00
tracked.field(&db); // tracked comes from prior revision
}