-
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 #573 from dhruvmanila/dhruv/recreate-panic
Fix panic when recreating tracked struct that was deleted in previous revision
- Loading branch information
Showing
8 changed files
with
87 additions
and
23 deletions.
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
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
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
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
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
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
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
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,35 @@ | ||
//! Test that re-creating a `tracked` struct after it was deleted in a previous | ||
//! revision doesn't panic. | ||
#![allow(warnings)] | ||
|
||
use salsa::Setter; | ||
|
||
#[salsa::input] | ||
struct MyInput { | ||
field: u32, | ||
} | ||
|
||
#[salsa::tracked] | ||
struct TrackedStruct<'db> { | ||
field: u32, | ||
} | ||
|
||
#[salsa::tracked] | ||
fn tracked_fn(db: &dyn salsa::Database, input: MyInput) -> Option<TrackedStruct<'_>> { | ||
if input.field(db) == 1 { | ||
Some(TrackedStruct::new(db, 1)) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
#[test] | ||
fn execute() { | ||
let mut db = salsa::DatabaseImpl::new(); | ||
let input = MyInput::new(&db, 1); | ||
assert!(tracked_fn(&db, input).is_some()); | ||
input.set_field(&mut db).to(0); | ||
assert_eq!(tracked_fn(&db, input), None); | ||
input.set_field(&mut db).to(1); | ||
assert!(tracked_fn(&db, input).is_some()); | ||
} |