Commit graph

78 commits

Author SHA1 Message Date
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
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
Bernardo Uriarte
b14d12ada9 avoid warnings in generated code 2022-08-26 18:51:51 +02: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
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
DropDemBits
5927ae23a3 Have users of SalsaStruct specify allowed options 2022-08-25 01:48:34 -04:00
XFFXFF
e86252d051 add synthetic_write to salsa::Database 2022-08-25 06:13:12 +08:00
Adam Andersson
18507f2ff7 fix some typos 2022-08-24 21:12:58 +02:00
andrzej.gluszak
73102b1e8e Fix clippy issues 2022-08-24 18:45:53 +02:00
XFFXFF
f5b0ff59d3 add runtime_mut and synthetic_write to HasJarsDyn 2022-08-24 20:01:00 +08:00
Andrzej Głuszak
8e27ecd098 Fix formatting 2022-08-24 00:10:07 +02:00
Andrzej Głuszak
fdc8018234 Cleanup 2022-08-23 23:38:19 +02:00
Andrzej Głuszak
43cd95fe47 Derive DebugWithDb 2022-08-23 23:26:07 +02:00
bors[bot]
d3f0077d21
Merge #369
369: Try to fix issue#340 r=XFFXFF a=zjp-CN

(WIP) 

Follow the instructions from https://github.com/salsa-rs/salsa/issues/340#issuecomment-1210153085.

Still not sure what to do with `fmt_index`...

Fix #340

Co-authored-by: zjp <jiping_zhou@foxmail.com>
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-22 13:42:18 +00:00
zjp
863ec4ac7f fix(debug_name): impl for InternedIngredient 2022-08-22 21:17:48 +08:00
zjp
4966acbc64 feat(literal): a helper to convert Ident to Literal 2022-08-22 20:22:57 +08:00
Charles Lew
7267452ff1 Implement Setter API 2022-08-22 19:22:47 +08:00
Charles Lew
66b5d45995 Fix local doctest failure. 2022-08-22 19:22:37 +08:00
Bernardo Uriarte
cbbd05f5d5 update heck 2022-08-22 10:51:34 +02:00
zjp
f69d80b2c5 ix(fmt_index): impl for TrackedStructIngredient 2022-08-22 10:43:41 +08:00
zjp
b76ac29a09 fix(fmt_index): impl for InputFieldIngredient 2022-08-22 10:33:39 +08:00
zjp
af747c1aca fix(fmt_index): impl for accumulator 2022-08-22 10:04:47 +08:00
bors[bot]
3d727f60e2
Merge #363
363: Add method to change LRU capacity at runtime r=nikomatsakis a=XFFXFF

closes #355 

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-22 01:08:27 +00:00
zjp
525a9fec4c fix(fmt_index): proc macro expansion 2022-08-22 01:00:16 +08:00
zjp
0d7066c554 fix(clippy): follow the advice 2022-08-22 00:57:09 +08:00
zjp
70b0340b81 feat(fmt_index): added in Ingredient trait 2022-08-21 23:55:29 +08:00
bors[bot]
8dfc578edc
Merge #360
360: Permit renaming constructors, getters and setters r=nikomatsakis a=MihailMihov

The goal is to add an option `constructor_name` to `#[salsa::input]`, `#[salsa::interned]` and `#[salsa::tracked]` that allows changing the name of the generated constructor. After that add attributes `get` and `set` to the fields which allow overriding the names of the getters and setters. In the end the following snippet should compile and work:
```rust
#[salsa::interned(constructor = from_string)]
struct MyInterned {
    #[get(text)] #[set(set_text)] #[return_ref]
    field: String,
}

impl MyInterned {
    pub fn new(db: &dyn Db, s: impl Display) -> MyInterned {
        MyInterned::from_string(db, s.to_string())
    }

    pub fn field(self, db: &dyn Db) -> &str {
        self.text(db)
    }

    pub fn set_field(self, db: &mut dyn Db, id: String) {
        self.set_text(&mut db, id)
    }
}
```

resolves #332 

Co-authored-by: Mihail Mihov <mmihov.personal@gmail.com>
2022-08-21 10:37:21 +00:00
XFFXFF
04b70f54e3 lru can be changed at runtime 2022-08-21 10:02:45 +08:00
Mihail Mihov
958b063a60 Update input, interned and tracked structs to use specified getter and setter names 2022-08-21 01:52:54 +03:00
Mihail Mihov
eb4f97f533 Add get and set to FIELD_OPTION_ATTRIBUTES 2022-08-21 01:22:18 +03:00
Mihail Mihov
2970c16e77 Respect constructor_name option input, interned and tracked structs 2022-08-21 01:19:12 +03:00
Mihail Mihov
6cb1cb0a47 Add constructor_name option to Options 2022-08-21 01:16:45 +03:00
bors[bot]
5f3e0ec6f5
Merge #353
353: start documenting plumbing r=nikomatsakis a=nikomatsakis

Feedback desired! I am trying to document an overview of the new salsa 2022 plumbing. I'd love for folks to [read these docs and tell me if they make sense](https://deploy-preview-353--salsa-rs.netlify.app/plumbing.html).

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-18 23:43:44 +00:00
Niko Matsakis
06e0a04cb3 explain more about rev counter, include snippets 2022-08-18 19:37:59 -04:00
bors[bot]
eca8bad6e9
Merge #352
352: Add options to tracked funcitons for lru capacity  r=nikomatsakis a=XFFXFF

fixes #344 

Now we can write something like the following to set the lru capacity of tracked functions  
```rust
#[salsa::tracked(lru=32)]
fn my_tracked_fn(db: &dyn crate::Db, ...) { }
```

some details:  
* lru should not be combined with specify. We will report an error if people do #[salsa::tracked(lru = 32, specify)]
* set 0 as default capacity to disable LRU (Because I think doing this would make the code simpler when implementing `create_ingredients` of tracked functions).
* old salsa support to change lru capacity at runtime, [as noted here](https://salsa-rs.github.io/salsa/rfcs/RFC0004-LRU.html?highlight=change#reference-guide), but we do not support this now

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-18 10:37:38 +00:00
Niko Matsakis
a1a8533cef define how routes are created 2022-08-18 05:15:12 -04:00
XFFXFF
fc4d531d76 refactor and cargo fmt 2022-08-18 08:07:13 +08:00
XFFXFF
53785f1355 lru and specify can not be used together 2022-08-17 18:54:55 +08:00
XFFXFF
341fc80726 port more tests about lru 2022-08-17 18:54:55 +08:00
XFFXFF
d080e349ef make lru option work 2022-08-17 18:54:17 +08:00
Niko Matsakis
186c915b21 make outputs use DependencyIndex
It turns out that we have some outputs (accumulators) for which
it only makes sense to have a `DependencyIndex` (they don't have
individual keys to identify).
2022-08-17 04:43:25 -04:00
XFFXFF
2d59df39af parse the lru option 2022-08-17 07:22:45 +08:00
Niko Matsakis
689751b243 wire up salsa struct seletion, test it
We now delete entities and data associated with them!
Neat!
2022-08-16 17:55:32 -04:00
Niko Matsakis
66ffae1bb9 generalize push to always have a &mut route
We also track whether reset is required at the ingredient level.
For tracked struct fields, we were not using `push_mut`,
and I think that was an oversight.

The plan is to do a "dependent ingredient" interlinking pass
once the database is constructed.
2022-08-16 17:55:32 -04:00
Niko Matsakis
60cdce22e9 track "dependent functions" 2022-08-16 17:55:32 -04:00
Mihail Mihov
5fe3c08cb7 Pass the runtime to InputFieldIngredient's fetch 2022-08-13 13:04:19 +03:00