test for compile failure: lru can not be used with specify

This commit is contained in:
XFFXFF 2022-08-19 07:13:03 +08:00
parent 6fe5062548
commit 738dc3f878
4 changed files with 33 additions and 0 deletions

View file

@ -11,3 +11,4 @@ expect-test = "1.4.0"
parking_lot = "0.12.1"
test-log = "0.2.11"
env_logger = "*"
trybuild = "1.0"

View file

@ -0,0 +1,16 @@
#[salsa::jar(db = Db)]
struct Jar(MyInput, lru_can_not_be_used_with_specify);
trait Db: salsa::DbWithJar<Jar> {}
#[salsa::input(jar = Jar)]
struct MyInput {
field: u32,
}
#[salsa::tracked(jar = Jar, lru = 3, specify)]
fn lru_can_not_be_used_with_specify(db: &dyn Db, input: MyInput) -> u32 {
input.field(db)
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: `specify` and `lru` cannot be used together
--> tests/compile-fail/lru_can_not_be_used_with_specify.rs:11:38
|
11 | #[salsa::tracked(jar = Jar, lru = 3, specify)]
| ^^^^^^^
error[E0412]: cannot find type `lru_can_not_be_used_with_specify` in this scope
--> tests/compile-fail/lru_can_not_be_used_with_specify.rs:2:21
|
2 | struct Jar(MyInput, lru_can_not_be_used_with_specify);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

View file

@ -0,0 +1,5 @@
#[test]
fn compile_fail() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/compile-fail/*.rs");
}