diff --git a/salsa-2022-tests/tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-input.rs b/salsa-2022-tests/tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-input.rs new file mode 100644 index 00000000..10d9f727 --- /dev/null +++ b/salsa-2022-tests/tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-input.rs @@ -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 {} + +#[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, +} + +impl salsa::Database for Database {} + +impl Db for Database {} + +fn main() {} \ No newline at end of file diff --git a/salsa-2022-tests/tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-input.stderr b/salsa-2022-tests/tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-input.stderr new file mode 100644 index 00000000..5c52c233 --- /dev/null +++ b/salsa-2022-tests/tests/compile-fail/specify-does-not-work-if-the-key-is-a-salsa-input.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `MyInput: TrackedStructInDb` 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` is not implemented for `MyInput` + | + = help: the trait `TrackedStructInDb` is implemented for `MyTracked` +note: required by a bound in `function::specify::>::specify_and_record` + --> $WORKSPACE/components/salsa-2022/src/function/specify.rs + | + | C::Key: TrackedStructInDb>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `function::specify::>::specify_and_record`