salsa/tests/panic-when-creating-tracked-struct-outside-of-tracked-fn.rs

26 lines
504 B
Rust
Raw Normal View History

//! Test that creating a tracked struct outside of a
//! tracked function panics with an assert message.
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-17 10:41:56 +00:00
#[salsa::db]
#[derive(Default)]
struct Database {
storage: salsa::Storage<Self>,
}
2024-07-17 10:41:56 +00:00
#[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);
}