405: Include only identity fields by default in `DebugWithDb::debug` and add `DebugWithDb::debug_all` r=nikomatsakis a=vemoo
This addresses a couple of items of #397
I initially added a separate `DebugWithDb::fmt_all` method but then changed it to an extra parameter to make it easier to propagate to inner fields. Also tried introducing something like:
```rust
pub struct FormatterWithDb<'me, 'f, Db: ?Sized>{
fmt: &'me mut std::fmt::Formatter<'f>,
db: &'me Db,
include_all_fields: bool
}
```
to pass to `fmt`, but I gave up because the lifetimes got a bit unwieldy.
Co-authored-by: Bernardo Uriarte <berublan@gmail.com>
401: Support singleton inputs #337 r=nikomatsakis a=OLUWAMUYIWA
## What?
In #337, it was requested `Singleton` input option be made available for Input structs with a single field. This PR addresses that
## How?
I basically followed the mentoring instructions made available.
Fixes#337
Co-authored-by: OLUWAMUYIWA <onigbindemy@gmail.com>
Co-authored-by: Onigbinde Oluwamuyiwa Elijah <onigbindemy@gmail.com>
408: Exhaustive macros test r=nikomatsakis a=OLUWAMUYIWA
### What
Used `trybuild` to verify that incompatible options with salsa structs will not compile
Ref: #354
### How:
I created a `.rs` file for each salsa struct. I decided not to create one for each incompatible option, as this would only greatly increase the number of files.
Co-authored-by: OLUWAMUYIWA <onigbindemy@gmail.com>
Co-authored-by: Onigbinde Oluwamuyiwa Elijah <onigbindemy@gmail.com>
393: Allow "constant" tracked functions r=XFFXFF a=Skepfyr
Fixes#323.
This adds support for tracked functions with only a database as input,
that is, it does not take a salsa struct.
I'm not entirely convinced by this, it feels like it works somewhat accidentally and may be fragile to changes. I'm happy if this just get closed as I was mostly playing around to see how this worked.
This change has the odd side-effect of making this code work:
```rust
#[salsa::tracked]
fn tracked_fn(db: &dyn Db, unit: ()) -> u32 {
44
}
```
Co-authored-by: Jack Rickard <jack.rickard@outlook.com>
406: no need to generate a config struct for each field of `salsa::input` r=nikomatsakis a=XFFXFF
https://github.com/salsa-rs/salsa/pull/342 added `InputFieldIngredient` which replaces the `FunctionIngredient` for `salsa::input`, so we don't need to generate a config struct and `salsa::function::Configuration` impl for each field, beacuse they are only needed when we use `FunctionIngredient`
Co-authored-by: XFFXFF <1247714429@qq.com>
392: Allow creation of tracked methods r=nikomatsakis a=Skepfyr
Fixes#319.
This allows users to annotate impl blocks with `#[salsa::tracked]` and
then create tracked methods by marking individual functions with
`#[salsa::tracked]`.
Note this requires your code that looks like:
```rust
#[salsa::tracked(jar = Jar)]
impl MyInput {
#[salsa::tracked]
fn tracked_fn(self, db: &dyn Db) -> u32 {
self.field(db) * 2
}
}
```
You get an error if you annotate a method with `#[salsa::tracked]` but forget to mark the impl block.
It got messier than I was hoping but I think it turned out alright, this would look really pretty if we had [inherent associated types](https://github.com/rust-lang/rust/issues/8995), but we don't. Annoyingly even if that landed I think we'd still need the attribute on the impl block just so that it was possible to create the associated struct somewhere as you can't put types inside an impl block (and they aren't accessible if placed inside a function).
Co-authored-by: Jack Rickard <jack.rickard@outlook.com>
399: Make getters and setters have the visibility of their field r=nikomatsakis a=MihailMihov
resolves#398
Currently `#[salsa::input]` and `#[salsa::tracked]` structs made all getters and setters public, regardless of the visibility of the field and the getters for `#[salsa::interned]` had the visibility of the struct itself. This pull request changes the generated impl's to use the visibility of each field for it's getters and setters.
Co-authored-by: Mihail Mihov <mmihov.personal@gmail.com>
This changes tracked methods from being annotated with `#[tracked]` to
`#[salsa::tracked]`. This improves consistency and allows outputting a
nicer error message if someone forgets to put the attribute on the impl
block.
395: reduce amount of generated code for `DebugWithDb` r=nikomatsakis a=vemoo
Extract common code that was being repeated for each field of each salsa handled struct to `components/salsa-2022/src/debug.rs` module `helper`.
Co-authored-by: Bernardo Uriarte <berublan@gmail.com>
391: Fix derived-query-read diagram in the book r=nikomatsakis a=Skepfyr
This fixes the sort order of the backgrounds in the derived query read
diagram so that the flowchart is legible.
Co-authored-by: Jack Rickard <jack.rickard@outlook.com>
389: avoid warnings in generated code r=nikomatsakis a=vemoo
Addresses a couple of warnings that appear when I tried to use current master in https://github.com/dada-lang/dada.
Also added tests that will fail to compile if the macros generate warnings.
Co-authored-by: Bernardo Uriarte <berublan@gmail.com>