Commit graph

1352 commits

Author SHA1 Message Date
bors[bot]
4e9161e221
Merge #393
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>
2022-09-06 23:49:25 +00:00
Jack Rickard
5832ad3090
Replace () with Singleton Salsa struct 2022-09-06 00:34:00 +01:00
Jack Rickard
a9e24d8b0d
Allow "constant" tracked functions
This adds support for tracked functions with only a database as input,
that is, it does not take a salsa struct.
2022-09-06 00:33:43 +01:00
bors[bot]
bd7f27d72b
Merge #406
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>
2022-09-05 10:49:33 +00:00
bors[bot]
e0d07812fa
Merge #392
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>
2022-09-05 10:44:51 +00:00
XFFXFF
b55caff4ec no need to generate a config struct and corresponding impls for each field of salsa::input 2022-09-05 14:10:46 +08:00
Jack Rickard
bac4c668cf
Add more tests for tracked methods 2022-09-03 15:44:56 +01:00
Onigbinde Oluwamuyiwa Elijah
aa25761bd4
Merge branch 'salsa-rs:master' into singleton 2022-09-03 14:37:27 +01:00
OLUWAMUYIWA
975fc9d4ab ran cargo fmt 2022-09-03 14:32:42 +01:00
bors[bot]
79ca8e8ca7
Merge #403
403: fix typos r=XFFXFF a=zjp-CN



Co-authored-by: zjp <jiping_zhou@foxmail.com>
2022-09-02 23:24:19 +00:00
zjp
549f831e70 fix typos 2022-09-02 22:44:41 +08:00
OLUWAMUYIWA
25809151dd removed AllowedMode trait and added compile-fail tests 2022-09-02 13:09:28 +01:00
bors[bot]
68cb5e9212
Merge #399
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>
2022-09-02 09:26:30 +00:00
OLUWAMUYIWA
3ca70e6b04 cargo fmt 2022-09-02 03:02:51 +01:00
OLUWAMUYIWA
565c53d4dd Support singleton inputs 2022-09-02 02:54:21 +01:00
Mihail Mihov
0a3b74da57 Add compile-fail test for getter and setter visibility 2022-09-02 03:19:21 +03:00
Jack Rickard
2df88d2c33
Use #[salsa::tracked] for tracked methods
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.
2022-08-31 23:30:49 +01:00
Mihail Mihov
13facddde2 Fix field visibilities in calc-example 2022-09-01 00:28:01 +03:00
Mihail Mihov
55f20344d1 Use visibility of field in SalsaField in #[salsa::interned] getters 2022-08-31 23:49:09 +03:00
Mihail Mihov
3df74dc0ac Use visibility of field in SalsaField in #[salsa::tracked] struct getters and setters 2022-08-31 23:48:53 +03:00
Mihail Mihov
784828ec42 Use visibility of field in SalsaField in #[salsa::input] getters and setters 2022-08-31 22:59:37 +03:00
Mihail Mihov
3542f2a1e7 Add methods in SalsaField and SalsaStruct to get visibility of field 2022-08-31 22:58:56 +03:00
bors[bot]
657b85682b
Merge #395
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>
2022-08-31 09:02:33 +00:00
bors[bot]
93b3aab638
Merge #391
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>
2022-08-31 00:02:05 +00:00
Bernardo Uriarte
fd71561981 reduce amount of generated code for DebugWithDb
by moving part of it to `salsa-2022`
2022-08-30 18:03:18 +02:00
bors[bot]
1cabfdb077
Merge #390
390: Add some doc on `specify` r=nikomatsakis a=XFFXFF

Add some documentation to explain why `specify` only works if the key is a tracked struct created in the current query, as per [this](https://salsa.zulipchat.com/#narrow/stream/146365-good-first-issue/topic/questions.20about.20.60specify.60/near/295416521) zulip thread.  
I also added some tests to test that "specify" shouldn't work in some cases.

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-30 10:17:28 +00:00
bors[bot]
b41c9dd296
Merge #389
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>
2022-08-30 10:12:38 +00:00
Jack Rickard
dbc4154419
Allow creation of tracked methods
This allows users to annotate impl blocks with `#[salsa::tracked]` and
then create tracked methods by marking individual functions with
`#[tracked]`.
2022-08-28 23:28:30 +01:00
Jack Rickard
6febfdac8f
Fix derived-query-read diagram in the book
This fixes the sort order of the backgrounds in the derived query read
diagram so that the flowchart is legible.
2022-08-28 12:17:43 +01:00
XFFXFF
cece3d840a run compile_fail test only on stable 2022-08-27 16:01:04 +08:00
XFFXFF
f46f2ac202 fix typos 2022-08-27 07:52:18 +08:00
XFFXFF
f7519acb13 add a test for specify
`specify` does not work if the key is a `salsa::interned`
2022-08-27 07:51:35 +08:00
XFFXFF
82a6251ebc add a test for specify
`specify` does not work if the key is a `salsa::input`
2022-08-27 07:05:35 +08:00
XFFXFF
8e53905b87 add a test for specify
`specify` only works if the key is created in the current query.
2022-08-27 06:44:36 +08:00
XFFXFF
dbe8561721 add some docs for specify 2022-08-27 06:22:04 +08:00
bors[bot]
e99e45d35a
Merge #388
388: Update README.md r=XFFXFF a=tusharxoxoxo

Gramatical Error

Co-authored-by: Tushar Dahiya <tusharxoxoxo@gmail.com>
2022-08-26 21:52:00 +00:00
Bernardo Uriarte
b14d12ada9 avoid warnings in generated code 2022-08-26 18:51:51 +02:00
Tushar Dahiya
a360ea9371
Update README.md 2022-08-26 21:50:21 +05:30
bors[bot]
1363d78fe5
Merge #384
384: Remove RFCs section of the book r=nikomatsakis a=seanchen1991

Closes #382 

The RFCs section of the Salsa book lists RFCs that pertain to the older version of Salsa, not `salsa-2022`. As per [this](https://salsa.zulipchat.com/#narrow/stream/333573-salsa-2022/topic/What's.20the.20state.20of.20Salsa.20RFCs.3F/near/295118254) Zulip thread, the RFCs section is being removed. 

Co-authored-by: Sean Chen <seanchen11235@gmail.com>
2022-08-26 09:01:52 +00:00
bors[bot]
6ee0889948
Merge #383
383: Have users of `SalsaStruct` specify allowed options r=XFFXFF a=DropDemBits

This allows adding new options exclusively to `tracked`, `input`, `interned`, or any combination of them, without having to add support code to `SalsaStruct`.

The motivating example is #337, where `input` needs to accept a new `singleton` option, but `tracked` and `interned` should reject it.

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2022-08-25 23:39:01 +00:00
DropDemBits
62f0ceb665 Run cargo fmt 2022-08-25 13:19:57 -04:00
Sean Chen
5aefc92d61 Remove links to removed RFCs 2022-08-25 09:23:59 -05:00
Sean Chen
2114c8ae0c Remove RFCs section of the book 2022-08-25 08:55:22 -05:00
bors[bot]
5c63715a95
Merge #381
381: fix typos r=nikomatsakis a=Aadamandersson



Co-authored-by: Adam Andersson <adam.m.andersson@gmail.com>
2022-08-25 10:34:44 +00:00
bors[bot]
63fb4ad24c
Merge #376 #379
376: add `synthetic_write` r=nikomatsakis a=XFFXFF

fixes #364 

add `synthetic_write` and use it in test `lru_keeps_dependency_info`, the test will now be broken. We can use `lru_keeps_dependency_info` as a test for https://github.com/salsa-rs/salsa/issues/365, which already has a pr https://github.com/salsa-rs/salsa/pull/371.

379: Update test.yml r=nikomatsakis a=agluszak

- Add names to steps
- No need to run clippy AND check (https://stackoverflow.com/questions/57449356/is-cargo-clippy-a-superset-of-cargo-check)
- Run clippy on all targets with all features
- Fix issues reported by clippy

Co-authored-by: XFFXFF <1247714429@qq.com>
Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
Co-authored-by: andrzej.gluszak <andrzej.gluszak@mpi-sp.org>
2022-08-25 10:30:34 +00:00
bors[bot]
7872a53ef2
Merge #375
375: Editing pass over the Overview, Tutorial, and Reference sections of the book r=nikomatsakis a=seanchen1991

This PR includes a number of proposed changes, mostly fixing typos, a few additions/rearrangements where I thought it made sense, as well as a couple of questions delineated in brackets, to the book in an effort to polish it up a bit. 

There's also a question around whether the book should standardize around 'Salsa' or 'salsa'. 

Co-authored-by: Sean Chen <seanchen11235@gmail.com>
Co-authored-by: Sean Chen <skypemaster007@gmail.com>
2022-08-25 10:27:21 +00:00
DropDemBits
5927ae23a3 Have users of SalsaStruct specify allowed options 2022-08-25 01:48:34 -04:00
XFFXFF
266505d58e remove synthetic_write from Runtime 2022-08-25 13:46:58 +08:00
XFFXFF
f899551962 fix unused import 2022-08-25 06:43:47 +08:00
XFFXFF
8e754ec0d7 add report_untracked_read to salsa::Database 2022-08-25 06:30:27 +08:00