salsa/tests/compile-fail/panic-when-reading-fields-of-tracked-structs-from-older-revisions.rs
Niko Matsakis 68a3a7fceb wip
2024-07-19 08:05:39 -04:00

24 lines
524 B
Rust

use salsa::prelude::*;
#[salsa::input]
struct MyInput {
field: u32,
}
#[salsa::tracked]
struct MyTracked<'db> {
field: u32,
}
#[salsa::tracked]
fn tracked_fn<'db>(db: &'db dyn salsa::Database, input: MyInput) -> MyTracked<'db> {
MyTracked::new(db, input.field(db) / 2)
}
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);
tracked.field(&db); // tracked comes from prior revision
}