2023-06-13 20:34:48 +00:00
|
|
|
//! Test that creating a tracked struct outside of a
|
|
|
|
//! tracked function panics with an assert message.
|
|
|
|
|
|
|
|
#[salsa::jar(db = Db)]
|
2024-05-24 01:16:30 +00:00
|
|
|
struct Jar(MyTracked<'_>);
|
2023-06-13 20:34:48 +00:00
|
|
|
|
|
|
|
trait Db: salsa::DbWithJar<Jar> {}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2024-05-24 01:16:30 +00:00
|
|
|
struct MyTracked<'db> {
|
2023-06-13 20:34:48 +00:00
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[salsa::db(Jar)]
|
|
|
|
#[derive(Default)]
|
|
|
|
struct Database {
|
|
|
|
storage: salsa::Storage<Self>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl salsa::Database for Database {}
|
|
|
|
|
|
|
|
impl Db 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);
|
|
|
|
}
|