salsa/tests/panic-when-creating-tracked-struct-outside-of-tracked-fn.rs
Niko Matsakis 7443277381 wip
2024-07-17 06:41:56 -04:00

25 lines
504 B
Rust

//! Test that creating a tracked struct outside of a
//! tracked function panics with an assert message.
#[salsa::tracked]
struct MyTracked<'db> {
field: u32,
}
#[salsa::db]
#[derive(Default)]
struct Database {
storage: salsa::Storage<Self>,
}
#[salsa::db]
impl salsa::Database for Database {}
#[test]
#[should_panic(
expected = "cannot create a tracked struct disambiguator outside of a tracked function"
)]
fn execute() {
let db = Database::default();
MyTracked::new(&db, 0);
}