mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-11-24 20:20:26 +00:00
add tests that show improved spans
This commit is contained in:
parent
1acbf2b0d4
commit
e2f6437890
5 changed files with 95 additions and 2 deletions
|
@ -1,8 +1,8 @@
|
|||
error[E0599]: no method named `set_id_one` found for struct `MyInput` in the current scope
|
||||
--> tests/compile-fail/input_struct_id_fields_no_setters.rs:30:11
|
||||
|
|
||||
7 | #[salsa::input(jar = Jar)]
|
||||
| -------------------------- method `set_id_one` not found for this struct
|
||||
8 | struct MyInput {
|
||||
| ------- method `set_id_one` not found for this struct
|
||||
...
|
||||
30 | input.set_id_one(1);
|
||||
| ^^^^^^^^^^ help: there is a method with a similar name: `id_one`
|
||||
|
|
27
salsa-2022-tests/tests/compile-fail/span-input-setter.rs
Normal file
27
salsa-2022-tests/tests/compile-fail/span-input-setter.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
#[salsa::jar(db = Db)]
|
||||
pub struct Jar(MyInput);
|
||||
|
||||
pub trait Db: salsa::DbWithJar<Jar> {}
|
||||
|
||||
#[salsa::db(Jar)]
|
||||
#[derive(Default)]
|
||||
struct Database {
|
||||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
#[salsa::input]
|
||||
pub struct MyInput {
|
||||
field: u32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut db = Database::default();
|
||||
let input = MyInput::new(&mut db, 22);
|
||||
|
||||
input.field(&db);
|
||||
input.set_field(22);
|
||||
}
|
18
salsa-2022-tests/tests/compile-fail/span-input-setter.stderr
Normal file
18
salsa-2022-tests/tests/compile-fail/span-input-setter.stderr
Normal file
|
@ -0,0 +1,18 @@
|
|||
error[E0308]: mismatched types
|
||||
--> tests/compile-fail/span-input-setter.rs:26:21
|
||||
|
|
||||
26 | input.set_field(22);
|
||||
| --------- ^^ expected `&mut dyn Db`, found integer
|
||||
| |
|
||||
| arguments to this method are incorrect
|
||||
|
|
||||
= note: expected mutable reference `&mut dyn Db`
|
||||
found type `{integer}`
|
||||
note: method defined here
|
||||
--> tests/compile-fail/span-input-setter.rs:18:5
|
||||
|
|
||||
16 | #[salsa::input]
|
||||
| ---------------
|
||||
17 | pub struct MyInput {
|
||||
18 | field: u32,
|
||||
| ^^^^^
|
30
salsa-2022-tests/tests/compile-fail/span-tracked-getter.rs
Normal file
30
salsa-2022-tests/tests/compile-fail/span-tracked-getter.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
#[salsa::jar(db = Db)]
|
||||
pub struct Jar(MyTracked, my_fn);
|
||||
|
||||
pub trait Db: salsa::DbWithJar<Jar> {}
|
||||
|
||||
#[salsa::db(Jar)]
|
||||
#[derive(Default)]
|
||||
struct Database {
|
||||
storage: salsa::Storage<Self>,
|
||||
}
|
||||
|
||||
impl salsa::Database for Database {}
|
||||
|
||||
impl Db for Database {}
|
||||
|
||||
#[salsa::tracked]
|
||||
pub struct MyTracked {
|
||||
field: u32,
|
||||
}
|
||||
|
||||
#[salsa::tracked]
|
||||
fn my_fn(db: &dyn crate::Db) {
|
||||
let x = MyTracked::new(db, 22);
|
||||
x.field(22);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut db = Database::default();
|
||||
my_fn(&db);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
error[E0308]: mismatched types
|
||||
--> tests/compile-fail/span-tracked-getter.rs:24:13
|
||||
|
|
||||
24 | x.field(22);
|
||||
| ----- ^^ expected `&dyn Db`, found integer
|
||||
| |
|
||||
| arguments to this method are incorrect
|
||||
|
|
||||
= note: expected reference `&dyn Db`
|
||||
found type `{integer}`
|
||||
note: method defined here
|
||||
--> tests/compile-fail/span-tracked-getter.rs:18:5
|
||||
|
|
||||
16 | #[salsa::tracked]
|
||||
| -----------------
|
||||
17 | pub struct MyTracked {
|
||||
18 | field: u32,
|
||||
| ^^^^^
|
Loading…
Reference in a new issue