mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 12:16:25 +00:00
Merge pull request #566 from MichaReiser/const-query
Some checks failed
Book / Book (push) Has been cancelled
Test / Test (false, beta) (push) Has been cancelled
Test / Test (false, stable) (push) Has been cancelled
Test / Test (true, nightly) (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
Some checks failed
Book / Book (push) Has been cancelled
Test / Test (false, beta) (push) Has been cancelled
Test / Test (false, stable) (push) Has been cancelled
Test / Test (true, nightly) (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
Fix const queries with custom `Db` trait
This commit is contained in:
commit
f608ff8b24
2 changed files with 16 additions and 1 deletions
|
@ -190,7 +190,7 @@ macro_rules! setup_tracked_fn {
|
|||
fn id_to_input<$db_lt>(db: &$db_lt Self::DbView, key: salsa::Id) -> Self::Input<$db_lt> {
|
||||
$zalsa::macro_if! {
|
||||
if $needs_interner {
|
||||
$Configuration::intern_ingredient(db).data(db, key).clone()
|
||||
$Configuration::intern_ingredient(db).data(db.as_dyn_database(), key).clone()
|
||||
} else {
|
||||
$zalsa::FromId::from_id(key)
|
||||
}
|
||||
|
|
|
@ -2,13 +2,28 @@
|
|||
//! compiles and executes successfully.
|
||||
#![allow(warnings)]
|
||||
|
||||
use crate::common::LogDatabase;
|
||||
|
||||
mod common;
|
||||
|
||||
#[salsa::tracked]
|
||||
fn tracked_fn(db: &dyn salsa::Database) -> u32 {
|
||||
44
|
||||
}
|
||||
|
||||
#[salsa::tracked]
|
||||
fn tracked_custom_db(db: &dyn LogDatabase) -> u32 {
|
||||
44
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute() {
|
||||
let mut db = salsa::DatabaseImpl::new();
|
||||
assert_eq!(tracked_fn(&db), 44);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute_custom() {
|
||||
let mut db = common::LoggerDatabase::default();
|
||||
assert_eq!(tracked_custom_db(&db), 44);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue