Commit graph

1298 commits

Author SHA1 Message Date
Nodir Turakulov
eeac4f8d33
Implementing the Default trait 2024-01-08 18:25:30 -08:00
Niko Matsakis
f1d318a279
Merge pull request #450 from DropDemBits/placement-new-jars
Initialize jars in-place
2023-11-09 10:25:26 +00:00
Niko Matsakis
741a2c0e77
enable merge queues 2023-11-09 05:22:08 -05:00
Niko Matsakis
703794b1c7
Merge pull request #461 from Y-Nak/provide-access-to-ingredient-index
Provide a public API to obtain `IngredientIndex`
2023-11-09 10:21:37 +00:00
Niko Matsakis
143cd8ace5
Merge pull request #451 from xffxff/old_salsa_link
add a link to the older version of Salsa in the document
2023-11-09 05:09:53 -05:00
XFFXFF
fa4dc3ccfe update the link to old salsa 2023-10-29 10:05:08 +08:00
XFFXFF
c3a979f72c deploy both the latest and specified older version of salsa book 2023-10-29 10:02:29 +08:00
xffxff
739d0da4e3 add a link to the old version of Salsa in the document 2023-10-29 10:02:08 +08:00
Niko Matsakis
6ac3724e0a
Merge pull request #449 from DropDemBits/assert-on-tracked-struct-outside-of-tracked-fn
Improve assert message when creating a tracked struct outside of a tracked function
2023-10-28 06:58:14 -04:00
Niko Matsakis
c6ab69196a
Merge pull request #460 from cuviper/indexmap-2
Upgrade to indexmap 2
2023-10-28 06:57:23 -04:00
Yoshitomo Nakanishi
d0ca81e58f Update macro test fixtures to reflect rustc diagnostics updates 2023-10-08 21:47:01 +02:00
Yoshitomo Nakanishi
b295f5aef7 Remove unnecessary mut from make_fn_return_ref 2023-10-08 20:41:55 +02:00
Yoshitomo Nakanishi
59f094f512 Provide public API to get IngredientIndex 2023-10-08 20:40:52 +02:00
Josh Stone
db3ef9a2ba Upgrade to indexmap 2 2023-09-29 17:11:34 -07:00
DropDemBits
f1a141a6c0
Update "Jars and Ingredients" to reflect the in-place init changes 2023-06-18 00:13:54 -04:00
DropDemBits
5b8412656c
Initialize jars in-place
Requires unsafe, since Rust currently doesn't have built-in
support for guaranteed in-place initialization. Unfortunately,
this unsafety propagates to making `Jar` unsafe to implement
in order to guarantee that the jar is initialized, but since
the preferred way to implement it is via `salsa::jar`, this
won't impact most users.
2023-06-14 01:09:58 -04:00
DropDemBits
22646a8fb4
Improve assert message when creating a tracked struct outside of a tracked function 2023-06-13 16:35:28 -04:00
bors[bot]
d4a94fbf07
Merge #440
440: Change the constructor of `salsa::Id` to const fn r=XFFXFF a=Y-Nak

This change is motivated to allow interned structs to have default const instances and prefill them in db initialization.

A specific example is managing symbols as a salsa interned struct in a compiler implementation. By declaring keywords as `const` symbols, we can handle keywords without going through their internal representation as rustc does (ref: [rustc_span::symbol](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/symbol.rs)). 
Conceptually, it'd look like the one below.

```rust
#[salsa::interned]
pub struct Symbol {
    data: String,
}

const SELF_SYM: Symbol = Symbol(salsa::Id::from_u32(1))
...

/// This function is called in db initialization.
fn prefill(db: &dyn HirDb) {
       Symbol::new(db, "self".to_string());
       ...
}
```

Co-authored-by: Yoshitomo Nakanishi <yurayura.rounin.3@gmail.com>
2023-04-24 08:45:47 +00:00
Yoshitomo Nakanishi
cbafc307fc Fix trybuild ui test to adapt the change of rustc error message 2023-04-22 11:16:51 +02:00
Yoshitomo Nakanishi
5718229882 Change the constructor of salsa::Id to const fn 2023-04-12 13:36:17 +02:00
bors[bot]
67d290dc26
Merge #439
439: Run CI on trybuild test updates r=XFFXFF a=DropDemBits

See https://github.com/salsa-rs/salsa/pull/436#issuecomment-1473737721

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2023-03-23 00:45:53 +00:00
DropDemBits
968f84d244
Run CI on trybuild test updates 2023-03-21 11:55:20 -04:00
bors[bot]
a327acc126
Merge #435
435: Allow `clippy::needless_lifetimes` on tracked method getters r=XFFXFF a=DropDemBits

The tracked method generation adds an extra `__db` lifetime to the signature, but clippy complains that this lifetime can be elided in some cases, so add an allow to silence this warning.

Unfortunately clippy doesn't lint inside of the warning tests, so those tests don't do anything to check that no clippy warnings are generated.

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2023-03-17 12:32:20 +00:00
bors[bot]
508a03b40a
Merge #436
436: Update trybuild tests r=XFFXFF a=DropDemBits

Rust 1.68 changed how the help suggestion text renders, and shows a diff for the suggested change.

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2023-03-17 12:26:29 +00:00
DropDemBits
ee762e8bdf
Update trybuild tests
Rust 1.68 changed how the help suggestion text renders, showing a diff
for the suggested change.
2023-03-15 10:37:08 -04:00
DropDemBits
7c8647e572
Allow clippy::needless_lifetimes on tracked method getters
Previously, this would necessitate having to manually add an allow for this
clippy lint, since an extra `'db` lifetime was added to the signature.
2023-03-15 09:56:00 -04:00
bors[bot]
ef7c0f12c8
Merge #433
433: Update videos.md with architecture walkthrough r=XFFXFF a=pervognsen



Co-authored-by: Per Vognsen <per.vognsen@gmail.com>
2023-02-10 10:01:55 +00:00
Per Vognsen
d817d14d1e Update videos.md with architecture walkthrough 2023-02-03 17:45:17 +07:00
bors[bot]
20c7834ff3
Merge #428
428: salsa-2022: fix hanging cancellations due to cvar not being notified r=nikomatsakis a=manapointer

This PR fixes an issue with the `cvar` condvar field of `Shared<DB>` not being notified when `Arc<Shared<DB>>`s were getting dropped. 

Previously, the condvar was being notified here:

```rust
impl<DB> Drop for Shared<DB>
where
    DB: HasJars,
{
    fn drop(&mut self) {
        self.cvar.notify_all();
    }
}
```

However, because this is implemented on `Shared<DB>`, the `drop` code only ran after all `Arc<Shared<DB>>`s (including that of the actual database and not just its snapshots) had dropped first, even though the intention was for the `drop` code to run when each individual `Arc<Shared<DB>>` was dropped so that the condvar would be notified each time.

To fix this, I've modified the `Shared<DB>` struct to instead hold `Arc`s to both the jars and the condvar, and `Storage` now holds `Shared<DB>` directly rather than `Arc<Shared<DB>>`. When `Shared<DB>` is dropped, it first drops its `Arc` for the jars, and then notifies the condvar.

## Note 
On my local branch I have a test case for this functionality, although it relied on timing using `std:🧵:sleep`. I figured this was less than ideal, so I decided not to include it in this PR - I'd love to get feedback on a better way to test this!

Co-authored-by: manapointer <manapointer@gmail.com>
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-12-29 16:37:53 +00:00
Niko Matsakis
ce4b041048
Update components/salsa-2022/src/storage.rs 2022-12-29 11:37:06 -05:00
manapointer
f1a775c355 update docs to be accurate to the change 2022-12-25 18:18:11 -08:00
manapointer
57b848da3e impl drop for storage 2022-12-25 18:10:42 -08:00
manapointer
2fc0a3c08f fix cvar not being notified when Arc<Shared<DB>> is dropped 2022-12-22 15:46:28 -08:00
bors[bot]
252d21e358
Merge #423
423: salsa 2022: fix input macro set_* being off by one if id field present r=XFFXFF a=jhgg

This PR fixes an issue with code generation for `#[salsa::input]` struct's `set_` methods. 

Consider the following code:

```rust
#[salsa::input(jar = Jar)]
struct BuggedInput {
    #[id]
    id: u32,
    other: String,
}
```

This will expand to:

```rust
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug)]
struct BuggedInput(salsa::Id);

impl BuggedInput {
     // snip...
    fn set_other<'db>(
        self,
        __db: &'db mut <Jar as salsa:🫙:Jar<'_>>::DynDb,
    ) -> salsa::setter::Setter<'db, BuggedInput, u32> {
        //                                       ^^^ wrong type (should be `String`)
        let (__jar, __runtime) = <_ as salsa::storage::HasJar<Jar>>::jar_mut(__db);
        let __ingredients =
            <Jar as salsa::storage::HasIngredientsFor<BuggedInput>>::ingredient_mut(__jar);
        salsa::setter::Setter::new(__runtime, self, &mut __ingredients.0)
        //                                                             ^ wrong index (should be `1`)
   }
}
```

Here we can see that the generated `set_other` impl is improperly setting the `id` field. This bug is caused because the filtering of the id fields in `InputStruct::all_set_field_names` causes a mismatch in `InputStruct::input_inherent_impl` when zipped with the field indices and types.

This PR changes `all_set_field_names` to return an `Option<&syn::Ident>` where the None is provided when a setter should not be generated, thus not causing index mismatches because no filtering occurs. Instead, we filter inside of `input_inherent_impl` after all the zips have been applied to the iterator.

After this PR, the code generated is now correct:

```rust
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug)]
struct BuggedInput(salsa::Id);

impl BuggedInput {
     // snip...
    fn set_other<'db>(
        self,
        __db: &'db mut <Jar as salsa:🫙:Jar<'_>>::DynDb,
    ) -> salsa::setter::Setter<'db, BuggedInput, String> {
        let (__jar, __runtime) = <_ as salsa::storage::HasJar<Jar>>::jar_mut(__db);
        let __ingredients =
            <Jar as salsa::storage::HasIngredientsFor<BuggedInput>>::ingredient_mut(__jar);
        salsa::setter::Setter::new(__runtime, self, &mut __ingredients.1)
    }
}
```


Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-11-29 04:54:45 +00:00
bors[bot]
328e459bee
Merge #426
426: update compile fail tests for latest stable rustc r=XFFXFF a=XFFXFF



Co-authored-by: XFFXFF <1247714429@qq.com>
2022-11-29 04:46:33 +00:00
XFFXFF
51f1f0c36d update compile fail tests for latest stable rustc 2022-11-29 12:36:12 +08:00
Jake Heinz
dd10b16964 salsa 2022: fix input macro set_* being off by one if id field present 2022-11-04 23:39:35 +00:00
bors[bot]
30b5e9760a
Merge #412
412: Fix race condition in interned data r=nikomatsakis a=Skepfyr

In some scenarios the `InternedIngredient` could return two different ids for the same data if called in parallel.

Co-authored-by: Jack Rickard <jack.rickard@outlook.com>
2022-09-27 22:48:54 +00:00
bors[bot]
ccd604d028
Merge #413
413: panic when reading fields of tracked structs from older revisions r=nikomatsakis a=XFFXFF

fix #407 

Co-authored-by: XFFXFF <1247714429@qq.com>
Co-authored-by: zhou fan <1247714429@qq.com>
2022-09-26 20:41:48 +00:00
XFFXFF
f48ca09a65 add empty dependencies back 2022-09-26 10:58:21 +00:00
XFFXFF
589bbeb65e Revert "remove unused variables and functions"
This reverts commit a2be847e1a.
2022-09-26 10:51:23 +00:00
XFFXFF
8f85d4ee27 cargo fmt 2022-09-26 09:15:10 +00:00
XFFXFF
409ed367c2 using flat-map trick 2022-09-26 09:14:30 +00:00
zhou fan
6239fc217a
add a comment
Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
2022-09-26 17:09:19 +08:00
Jack Rickard
c58ff26d87
Simplify interning by restricting deletes 2022-09-25 22:33:37 +01:00
XFFXFF
a8e16a72d2 update test: don't need mut reference when create inputs 2022-09-25 01:38:41 +00:00
XFFXFF
cc6ab647fa refactor outputs method of LocalState 2022-09-25 01:21:39 +00:00
XFFXFF
e7c7f386fe fix accumulator: clear the outdated accumulated values 2022-09-25 00:24:16 +00:00
XFFXFF
1214610451 remove inputs method of QueryEdges 2022-09-24 23:59:25 +00:00
XFFXFF
559c02ba80 update a test 2022-09-24 23:59:25 +00:00