add a test for specify

`specify` does not work if the key is a `salsa::input`
This commit is contained in:
XFFXFF 2022-08-27 07:05:35 +08:00
parent 8e53905b87
commit 82a6251ebc
2 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,35 @@
//! Test that `specify` does not work if the key is a `salsa::input`
//! compilation fails
#![allow(warnings)]
#[salsa::jar(db = Db)]
struct Jar(MyInput, MyTracked, tracked_fn);
trait Db: salsa::DbWithJar<Jar> {}
#[salsa::input(jar = Jar)]
struct MyInput {
field: u32,
}
#[salsa::tracked(jar = Jar)]
struct MyTracked {
field: u32,
}
#[salsa::tracked(jar = Jar, specify)]
fn tracked_fn(db: &dyn Db, input: MyInput) -> MyTracked {
MyTracked::new(db, input.field(db) * 2)
}
#[salsa::db(Jar)]
#[derive(Default)]
struct Database {
storage: salsa::Storage<Self>,
}
impl salsa::Database for Database {}
impl Db for Database {}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0277]: the trait bound `MyInput: TrackedStructInDb<dyn Db>` is not satisfied
--> tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-input.rs:21:28
|
20 | #[salsa::tracked(jar = Jar, specify)]
| ------------------------------------- required by a bound introduced by this call
21 | fn tracked_fn(db: &dyn Db, input: MyInput) -> MyTracked {
| ^^^^^ the trait `TrackedStructInDb<dyn Db>` is not implemented for `MyInput`
|
= help: the trait `TrackedStructInDb<DB>` is implemented for `MyTracked`
note: required by a bound in `function::specify::<impl FunctionIngredient<C>>::specify_and_record`
--> $WORKSPACE/components/salsa-2022/src/function/specify.rs
|
| C::Key: TrackedStructInDb<DynDb<'db, C>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `function::specify::<impl FunctionIngredient<C>>::specify_and_record`