Commit graph

1095 commits

Author SHA1 Message Date
Sean Chen
454e5518d2 Start proofreading the 'how salsa works' section 2022-08-22 14:16:38 -05:00
Sean Chen
0f7a8c33ae Editing overview, tutorial, and reference sections 2022-08-22 13:03:03 -05:00
bors[bot]
6320991c8b
Merge #372
372: run `cargo test -p salsa-2022-tests` in CI r=nikomatsakis a=XFFXFF

* run `cargo test -p salsa-2022-tests` in CI
* check format first

Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-22 10:12:23 +00:00
XFFXFF
dfc3ff0f80 using cargo test --all 2022-08-22 18:09:35 +08:00
bors[bot]
0f3c887cb1
Merge #373
373: Cargo updates r=nikomatsakis a=vemoo

- Unify `parking_log` versions
- `test-env-log` has been renamed
- Update `heck`, `dashmap` and `hashlink` to theirs latest versions

With this `cargo tree --workspace --duplicates` now doesn't return anything, when in master it returned:
```
env_logger v0.7.1
[dev-dependencies]
└── salsa v0.17.0-pre.2 (/home/berni/Documents/src/salsa)

env_logger v0.9.0
└── salsa-2022-tests v0.1.0 (/home/berni/Documents/src/salsa/salsa-2022-tests)

getrandom v0.1.16
├── rand v0.7.3
│   └── rand_distr v0.2.2
│       [dev-dependencies]
│       └── salsa v0.17.0-pre.2 (/home/berni/Documents/src/salsa)
│   [dev-dependencies]
│   └── salsa v0.17.0-pre.2 (/home/berni/Documents/src/salsa)
└── rand_core v0.5.1
    ├── rand v0.7.3 (*)
    └── rand_chacha v0.2.2
        └── rand v0.7.3 (*)

getrandom v0.2.7
└── ahash v0.7.6
    └── hashbrown v0.11.2
        └── hashlink v0.7.0
            ├── salsa v0.17.0-pre.2 (/home/berni/Documents/src/salsa)
            └── salsa-2022 v0.1.0 (/home/berni/Documents/src/salsa/components/salsa-2022)
                ├── calc v0.1.0 (/home/berni/Documents/src/salsa/calc-example/calc)
                └── salsa-2022-tests v0.1.0 (/home/berni/Documents/src/salsa/salsa-2022-tests)

hashbrown v0.11.2 (*)

hashbrown v0.12.3
└── indexmap v1.9.1
    ├── salsa v0.17.0-pre.2 (/home/berni/Documents/src/salsa)
    └── salsa-2022 v0.1.0 (/home/berni/Documents/src/salsa/components/salsa-2022) (*)

humantime v1.3.0
└── env_logger v0.7.1 (*)

humantime v2.1.0
└── env_logger v0.9.0 (*)
```


Co-authored-by: Bernardo Uriarte <berublan@gmail.com>
2022-08-22 09:56:32 +00:00
Bernardo Uriarte
927d905e58 test-env-log has been renamed to test-log 2022-08-22 11:00:47 +02:00
Bernardo Uriarte
294bf2532c dev-dependency updates 2022-08-22 11:00:47 +02:00
Bernardo Uriarte
6dc4eb417b update dashmap and hashlink 2022-08-22 11:00:47 +02:00
Bernardo Uriarte
cbbd05f5d5 update heck 2022-08-22 10:51:34 +02:00
Bernardo Uriarte
78b066cff0 unify parking_lot version 2022-08-22 10:48:21 +02:00
XFFXFF
4fef5b8b2c check fmt first 2022-08-22 15:38:04 +08:00
XFFXFF
74e220ec39 update some tests 2022-08-22 15:32:29 +08:00
XFFXFF
9657247b2f trigger CI if you modify the relevent yaml 2022-08-22 15:27:09 +08:00
XFFXFF
60da89beb0 run salsa-2022-tests in CI 2022-08-22 15:22:34 +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
Mihail Mihov
6b1d24098b Add test override_new_get_set 2022-08-21 01:52:54 +03: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
Niko Matsakis
12e85cb778 wip type-checking, testing
need to cleanup this commit
2022-08-19 08:41:58 -04:00
Niko Matsakis
590c5ce8d3 regular structs for stmt,expr / track span
Docs are somewhat out of date.
Tracking span should enable re-use of type-check results.
2022-08-19 06:46:54 -04:00
Niko Matsakis
d83d3c44f8 package up the output into a Program 2022-08-19 05:53:33 -04:00
bors[bot]
80d0d14194
Merge #359 #361
359: fix: typos in tutorial ir chapter r=nikomatsakis a=dawnofmidnight

Looking at the tutorial, I believe `ProgramSource` is a typo for `SourceProgram`. I'm also pretty sure the `define` -> `derive` is correct, unless `define` is some attribute I'm not aware of.

361: test for compiling failure: lru can not be used with specify r=nikomatsakis a=XFFXFF

ref #354  
Test for compile failures with [tybuild](https://github.com/dtolnay/trybuild.git). This is an example to show how it works.

Co-authored-by: dawn <78233879+dawnofmidnight@users.noreply.github.com>
Co-authored-by: XFFXFF <1247714429@qq.com>
2022-08-18 23:46:02 +00: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]
02a5fc0e3e
Merge #358
358: add from impls for u32/usize r=nikomatsakis a=nikomatsakis

Make it easy to create an `Id`, especially from a `usize`

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-18 23:37:31 +00:00
XFFXFF
738dc3f878 test for compile failure: lru can not be used with specify 2022-08-19 07:13:03 +08:00
dawn
c0940415e3
fix: typos in tutorial ir chapter 2022-08-18 17:52:51 -04:00
Niko Matsakis
1c9c7280b7 add from impls for u32/usize 2022-08-18 16:36:05 -04:00
Niko Matsakis
030caa1d21
Update book/src/plumbing/jars_and_ingredients.md
Co-authored-by: Mihail Mihov <mmihov.personal@gmail.com>
2022-08-18 16:21:42 -04:00
Niko Matsakis
57834c553b
Update book/src/plumbing/jars_and_ingredients.md
Co-authored-by: Mihail Mihov <mmihov.personal@gmail.com>
2022-08-18 16:21:38 -04:00
bors[bot]
6fe5062548
Merge #357
357: Add missing `db` param in salsa::input book example r=nikomatsakis a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-08-18 12:21:18 +00:00
Lukas Wirth
e1a44b5d1d Add missing db param in book example 2022-08-18 13:00:43 +02:00
bors[bot]
5aebeeb9e5
Merge #356
356: make Id::from_u32 public r=nikomatsakis a=nikomatsakis

I made it private 'just because', but it turns out that dada uses it, and it seems reasonable.

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-18 10:56:53 +00:00
Niko Matsakis
bc01b9b0d1 make Id::from_u32 public
I made it private, but it turns out that dada uses it,
and it seems reasnable.
2022-08-18 06:48:57 -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
b6aec13b20 explain databases, runtimes, etc 2022-08-18 05:37:22 -04:00
Niko Matsakis
a1a8533cef define how routes are created 2022-08-18 05:15:12 -04:00
Niko Matsakis
5b7dff908d create chapters 2022-08-18 05:02:07 -04:00
Niko Matsakis
5b9da4a9c0 start documenting plumbing 2022-08-17 21:43:06 -04:00
XFFXFF
fc4d531d76 refactor and cargo fmt 2022-08-18 08:07:13 +08:00
bors[bot]
becaade31e
Merge #350
350: Accumulators r=nikomatsakis a=nikomatsakis

This branch fixes accumulators so they have the right *behavior* -- the implementation leaves something to be desired, though, in that you don't get very good re-use if you are using accumulators from inside tracked functions. Right now that is treated as an untracked read, so if you want to get good re-use you need a workaround like this one...

```rust
#[salsa::tracked(return_ref)]
fn accumulated_values(db: &dyn Db) -> Vec<T> {
    some_query::accumulated::<SomeAccumulator>(db)
}
```

...which would track and compare the new vs old vector and detect when they've changed.


Despite this limitation, this PR makes accumulators behave correctly with respect to the value taht gets returned and is good enough to Fix #313 in my opinion. I'll file an issue for the remaining improvements.

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-08-17 11:57:51 +00:00
Niko Matsakis
70b50a1813 fix formatting 2022-08-17 07:38:03 -04:00
Niko Matsakis
f147ee3917 demonstrate re-use workaround 2022-08-17 06:55:27 -04:00