Commit graph

97 commits

Author SHA1 Message Date
Bernardo Uriarte
3f74f36418 format 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
84445d5120 propagate include_all_fields option 2022-09-13 18:01:21 +02:00
Bernardo Uriarte
f4c6f4126e make DebugWithDb::debug only read identiy fields
and add `DebugWithDb::debug_all` which reads all fields
2022-09-13 18:01:19 +02:00
Onigbinde Oluwamuyiwa Elijah
fac05b3c9f
Merge branch 'salsa-rs:master' into singleton 2022-09-11 09:12:17 +01:00
OLUWAMUYIWA
7f691e3907 fixed difference in .stderr files 2022-09-07 22:19:05 +01:00
Onigbinde Oluwamuyiwa Elijah
a2fbd1c09e
Merge branch 'salsa-rs:master' into exhaustive-macros-test 2022-09-07 21:39:28 +01:00
OLUWAMUYIWA
08449c61b4 eshaustive tests to check salsa macros using the trybuild tool 2022-09-07 20:09:33 +01: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]
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
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
25809151dd removed AllowedMode trait and added compile-fail tests 2022-09-02 13:09:28 +01: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
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
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
XFFXFF
cece3d840a run compile_fail test only on stable 2022-08-27 16:01:04 +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
Bernardo Uriarte
b14d12ada9 avoid warnings in generated code 2022-08-26 18:51:51 +02: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
XFFXFF
8e754ec0d7 add report_untracked_read to salsa::Database 2022-08-25 06:30:27 +08:00
XFFXFF
e86252d051 add synthetic_write to salsa::Database 2022-08-25 06:13:12 +08:00
XFFXFF
2dc5a6c796 remove salsa_runtime 2022-08-25 06:01:23 +08:00
andrzej.gluszak
73102b1e8e Fix clippy issues 2022-08-24 18:45:53 +02:00
XFFXFF
0e0626abfa writes with jars_mut 2022-08-24 20:17:13 +08:00
XFFXFF
6776919f39 give salsa_runtime a default implementation 2022-08-24 20:11:48 +08:00
XFFXFF
f5b0ff59d3 add runtime_mut and synthetic_write to HasJarsDyn 2022-08-24 20:01:00 +08:00
XFFXFF
ea0df0fc03 impl runtime_mut for test in debug.rs 2022-08-24 19:04:35 +08:00
XFFXFF
2912e60938 impl salsa_runtime_mut for all the tests 2022-08-24 19:00:21 +08:00
XFFXFF
340e2d521d add synthetic write 2022-08-24 19:00:21 +08:00
bors[bot]
38c9b612dd
Merge #378
378: Derive DebugWithDb r=nikomatsakis a=agluszak

Closes #317 

Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
2022-08-24 10:37:09 +00:00
Andrzej Głuszak
0c3084d009 Test cleanup 2022-08-24 00:01:44 +02:00
Andrzej Głuszak
fbb219a527 Add a test 2022-08-23 23:54:18 +02:00
bors[bot]
9677935c9c
Merge #374
374: Add test for durability r=nikomatsakis a=crlf0710

Fixes #339 .

Co-authored-by: Charles Lew <crlf0710@gmail.com>
2022-08-23 19:23:51 +00:00
Charles Lew
8d956a8229 Add test for durability 2022-08-22 21:50:58 +08: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
Charles Lew
7267452ff1 Implement Setter API 2022-08-22 19:22:47 +08:00
XFFXFF
74e220ec39 update some tests 2022-08-22 15:32:29 +08:00
zjp
dfee2b8cee update tests 2022-08-22 15:23:58 +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
XFFXFF
e856f565b3 create inputs first in an lru test 2022-08-22 08:21:51 +08:00
XFFXFF
31a4c68fc7 fix typos: deponds -> depends 2022-08-22 05:53:25 +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
6645774d55 port another test about lru 2022-08-21 14:02:51 +08:00
XFFXFF
04b70f54e3 lru can be changed at runtime 2022-08-21 10:02:45 +08:00