salsa/tests/intern_access_in_different_revision.rs
Chayim Refael Friedman cf9efae0da
Make interned's last_interned_at equal Revision::MAX if they are interned outside a query (#804)
There is an assert that `last_interned_at >= last_changed_revision`, and it can fail without this, see the added test.
2025-04-22 10:42:17 +00:00

28 lines
625 B
Rust

use salsa::{Durability, Setter};
#[salsa::interned(no_lifetime)]
struct Interned {
field: u32,
}
#[salsa::input]
struct Input {
field: i32,
}
#[test]
fn the_test() {
let mut db = salsa::DatabaseImpl::default();
let input = Input::builder(-123456)
.field_durability(Durability::HIGH)
.new(&db);
// Create an intern in an early revision.
let interned = Interned::new(&db, 0xDEADBEEF);
// Trigger a new revision.
input
.set_field(&mut db)
.with_durability(Durability::HIGH)
.to(123456);
// Read the interned value
let _ = interned.field(&db);
}