-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #449 from DropDemBits/assert-on-tracked-struct-out…
…side-of-tracked-fn Improve assert message when creating a tracked struct outside of a tracked function
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
salsa-2022-tests/tests/panic-when-creating-tracked-struct-outside-of-tracked-fn.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! Test that creating a tracked struct outside of a | ||
//! tracked function panics with an assert message. | ||
|
||
#[salsa::jar(db = Db)] | ||
struct Jar(MyTracked); | ||
|
||
trait Db: salsa::DbWithJar<Jar> {} | ||
|
||
#[salsa::tracked(jar = Jar)] | ||
struct MyTracked { | ||
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); | ||
} |