-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #483 from nikomatsakis/salsa-2022-spans
improve spans for getters, constructors
- Loading branch information
Showing
11 changed files
with
123 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
salsa-2022-tests/tests/compile-fail/get-set-on-private-field.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
error[E0624]: method `field` is private | ||
--> tests/compile-fail/get-set-on-private-field.rs:29:11 | ||
| | ||
7 | #[salsa::input(jar = Jar)] | ||
| -------------------------- private method defined here | ||
9 | field: u32, | ||
| ---------- private method defined here | ||
... | ||
29 | input.field(&db); | ||
| ^^^^^ private method | ||
|
||
error[E0624]: method `set_field` is private | ||
--> tests/compile-fail/get-set-on-private-field.rs:30:11 | ||
| | ||
7 | #[salsa::input(jar = Jar)] | ||
| -------------------------- private method defined here | ||
9 | field: u32, | ||
| ----- private method defined here | ||
... | ||
30 | input.set_field(&mut db).to(23); | ||
| ^^^^^^^^^ private method |
4 changes: 2 additions & 2 deletions
4
salsa-2022-tests/tests/compile-fail/input_struct_id_fields_no_setters.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 18 additions & 0 deletions
18
salsa-2022-tests/tests/compile-fail/span-input-setter.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 30 additions & 0 deletions
30
salsa-2022-tests/tests/compile-fail/span-tracked-getter.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
18 changes: 18 additions & 0 deletions
18
salsa-2022-tests/tests/compile-fail/span-tracked-getter.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
| ^^^^^ |