-
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 #523 from MichaReiser/tracked-fn-interned
Allow interned values as tracked function arguments
- Loading branch information
Showing
3 changed files
with
35 additions
and
10 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
10 changes: 0 additions & 10 deletions
10
tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-interned.stderr
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,29 @@ | ||
//! Test that a `tracked` fn on a `salsa::interned` | ||
//! compiles and executes successfully. | ||
#[salsa::interned] | ||
struct Name<'db> { | ||
name: String, | ||
} | ||
|
||
#[salsa::tracked] | ||
fn tracked_fn<'db>(db: &'db dyn salsa::Database, name: Name<'db>) -> String { | ||
name.name(db).clone() | ||
} | ||
|
||
#[salsa::db] | ||
#[derive(Default)] | ||
struct Database { | ||
storage: salsa::Storage<Self>, | ||
} | ||
|
||
#[salsa::db] | ||
impl salsa::Database for Database {} | ||
|
||
#[test] | ||
fn execute() { | ||
let db = Database::default(); | ||
let name = Name::new(&db, "Salsa".to_string()); | ||
|
||
assert_eq!(tracked_fn(&db, name), "Salsa"); | ||
} |