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

Fix const queries with custom `Db` trait
This commit is contained in:
Niko Matsakis 2024-08-20 20:32:27 +00:00 committed by GitHub
commit f608ff8b24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -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)
}

View file

@ -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);
}