Commit graph

521 commits

Author SHA1 Message Date
Niko Matsakis
82872192b4 return_ref on tracked fn 2024-07-18 06:13:57 -04:00
Niko Matsakis
b7e6bc62af make methods work 2024-07-18 06:03:34 -04:00
Niko Matsakis
585b720fff wip 2024-07-17 09:14:20 -04:00
Niko Matsakis
8f8528a205 wip 2024-07-17 08:45:49 -04:00
Niko Matsakis
2213729c4e wip 2024-07-17 08:42:06 -04:00
Niko Matsakis
daba89c278 wip 2024-07-17 08:21:07 -04:00
Niko Matsakis
4e295f2257 wip 2024-07-17 07:49:46 -04:00
Niko Matsakis
185c86bb5a wip 2024-07-17 06:51:50 -04:00
Niko Matsakis
7443277381 wip 2024-07-17 06:41:56 -04:00
Niko Matsakis
afd7bcfa78 wip 2024-07-17 06:14:43 -04:00
Niko Matsakis
b552852f29 wip 2024-07-17 06:08:34 -04:00
Niko Matsakis
30f122eaac wip 2024-07-17 05:47:56 -04:00
Niko Matsakis
5963e118b9 wip 2024-07-17 05:33:51 -04:00
Niko Matsakis
8a39bf029b wip 2024-07-16 06:04:01 -04:00
Niko Matsakis
612cec6703 wip 2024-07-15 20:29:36 -04:00
Niko Matsakis
4769e32d44 wip 2024-07-15 07:51:40 -04:00
Niko Matsakis
fdc363b65f wip 2024-07-15 07:46:23 -04:00
Niko Matsakis
57eb0c45b4 wip: iterate towards hello_world
Some checks failed
Book / Book (push) Has been cancelled
Test / Test (false, beta) (push) Has been cancelled
Test / Test (false, stable) (push) Has been cancelled
Test / Test (true, nightly) (push) Has been cancelled
Test / Miri (push) Has been cancelled
Book / Deploy (push) Has been cancelled
2024-07-14 13:49:59 -04:00
Niko Matsakis
231dc4f713 wip: inputs 2024-07-14 13:36:30 -04:00
Niko Matsakis
4c998c78e4 wip 2024-07-13 11:41:19 -04:00
Niko Matsakis
91cd757a90 macro for tracked struct 2024-07-13 07:56:14 -04:00
Niko Matsakis
a4e550065f autogenerate interned case 2024-07-13 07:01:31 -04:00
Niko Matsakis
dde7341f97 create macro-rules macros to encapsulate output
This is a new idea for how to manage procedural
macros, which I kind of hate.
2024-07-13 05:45:22 -04:00
Niko Matsakis
15106ff8ea reorganize plumbing 2024-07-12 07:11:31 -04:00
Niko Matsakis
65118a0fe6 Send + Sync requirements 2024-07-12 05:59:47 -04:00
Niko Matsakis
a1651c89d9 WIP 2024-07-11 21:35:37 -04:00
Niko Matsakis
2cfb75837b WIP 2024-07-11 07:30:26 -04:00
Niko Matsakis
15d5f213c5 WIP 2024-07-11 06:22:02 -04:00
Niko Matsakis
380b19cc39 remove debug_name from function ingredients 2024-07-06 08:42:15 -04:00
Niko Matsakis
aaf8f0bf4f remove debug_name field from interned 2024-07-06 08:40:09 -04:00
Niko Matsakis
204f4eea6f move struct debug name to Configuration 2024-07-06 08:34:59 -04:00
Niko Matsakis
e1920bdda6 require databases and ingredients to be static 2024-07-06 08:15:27 -04:00
Matthijs Brobbel
38070130a8
Remove some unused dependencies 2024-06-19 11:55:18 +02:00
Matthijs Brobbel
b3838b1ca7
Update book 2024-06-18 09:59:17 +02:00
Matthijs Brobbel
c7851112a5
Rename salsa-2022 to salsa 2024-06-18 09:40:21 +02:00
Matthijs Brobbel
db75ae00a2
Remove old salsa 2024-06-18 09:25:26 +02:00
Noah Lev
19b40c377f Add missing syn feature requirement
With the latest commit (283ccda), any project that uses Salsa hits tons
of internal errors within Salsa. That's because Salsa needs syn's `full`
feature, which was removed from the Cargo.toml as part of the Salsa 3.0
mega-PR. Because Salsa 1.0 still has the `full` feature in its
Cargo.toml, Cargo implicitly still enables `full` for Salsa 2022, and
thus the Salsa 2022 example projects compile fine -- even though any
external code using Salsa does not.
2024-06-17 13:36:37 -07:00
Niko Matsakis
1544ee97ce
Apply suggestions from code review
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Ryan Cumming <etaoins@gmail.com>
Co-authored-by: David Barsky <me@davidbarsky.com>
2024-06-15 06:09:10 -04:00
Niko Matsakis
bcad24c7f1 add a safety comment on Update
This was not obvious to me initially.
2024-06-13 08:05:00 -04:00
Niko Matsakis
c02f30a4d6 remove dead code from interned structs 2024-06-11 05:24:47 -04:00
Niko Matsakis
f91eeb931d remove dead code
tracked structs only support `'db` lifetimes
2024-06-11 05:20:04 -04:00
Niko Matsakis
53266837af remove "setter" function altogether
This...seems dated. We have `specify` which is
a more correct and principled version. Not sure
what `set` was meant to be but I don't see any
tests for it so...kill it.
2024-05-30 09:46:20 -04:00
Niko Matsakis
ce750dadf5 allow elided lifetimes in tracked fn return values 2024-05-30 09:40:47 -04:00
Niko Matsakis
b9ab8fcebd rustfmt has opinions 2024-05-30 08:46:15 -04:00
Niko Matsakis
0ad0be8095 pacify the merciless clippy 2024-05-30 08:40:18 -04:00
Niko Matsakis
88b964d18d use const _: () to disable clippy lints 2024-05-30 08:40:18 -04:00
Niko Matsakis
07d0ead9f4 return a NonNull instead of a &'db
In old code, we converted to a `&'db` when
creating a new tracked struct or interning,
but this value in fact persisted beyond the end
of `'db` (i.e., into the new revision).

We now refactor so that we create the `Foo<'db>`
from a `NonNull<T>` instead of a `&'db T`, and
then only create safe references when users
access fields.

This makes miri happy.
2024-05-30 01:59:49 -04:00
Niko Matsakis
81942f37e5 use Alloc not Box
to avoid uniqueness guarantees
2024-05-27 07:39:46 -04:00
Niko Matsakis
ce88a8f9ca apply cargo fmt 2024-05-25 16:25:06 -04:00
Niko Matsakis
68502ab27f 'db all the things 2024-05-24 07:16:50 -04:00
Niko Matsakis
1560634f96 support methods with 'db lifetimes 2024-05-24 07:16:50 -04:00
Niko Matsakis
b005820494 add a derive for DebugWithDb 2024-05-24 07:16:50 -04:00
Niko Matsakis
4f4d01958f generate a custom std::fmt::Debug impl
This leads less representation information
and in particular avoids serializing pointers.
2024-05-24 07:16:50 -04:00
Niko Matsakis
d98485d3cb add a derive for salsa::Update
And a test for it. This is required if you
want to have structures in your tracked structs.

Looks we need one for salsa::DebugWithDb, too.
2024-05-24 07:16:50 -04:00
Niko Matsakis
2800076857 update to syn 2.0 2024-05-24 07:16:50 -04:00
Niko Matsakis
06b70975e9 impl Update/Send/Sync
and add dedicated tests for that
2024-05-24 07:16:50 -04:00
Niko Matsakis
b4b49fbd1b split the Id conversion traits
We now have AsId (always present)
and FromId/LookupId (sometimes present).

AsId is no longer part of the
salsa public interface.

Replace the ad-hoc `salsa_id` etc methods with
calls to `AsId::as_id`.
2024-05-24 07:16:50 -04:00
Niko Matsakis
7519c3e2a6 extend IdentityInterner to be based on LookupId 2024-05-24 07:16:50 -04:00
Niko Matsakis
ab70786536 introduce LookupId trait
We are going to need it for tracked functions.
2024-05-24 07:16:50 -04:00
Niko Matsakis
cf2fa671f5 introduce IdLookup trait
We are going to need it for tracked functions.
2024-05-24 07:16:50 -04:00
Niko Matsakis
8d0f8fccbf remove unnecessary uses of AsId 2024-05-24 07:16:50 -04:00
Niko Matsakis
d361e8adfb add a 'db argument to SalsaStruct 2024-05-24 07:16:50 -04:00
Niko Matsakis
9607638d5d permit interned structs with lifetimes 2024-05-24 07:16:50 -04:00
Niko Matsakis
9d8a60b617 parameterize salsa_struct module 2024-05-24 07:16:50 -04:00
Niko Matsakis
0b8c27bc30 rename from TrackedStruct to just Struct
this will let us use different packages
but the same struct name from salsa struct
2024-05-24 07:16:50 -04:00
Niko Matsakis
5095d79d13 return a pointer from interning, not just id 2024-05-24 07:16:50 -04:00
Niko Matsakis
d92f2aa0a5 factor out useful helper fn 2024-05-24 07:16:50 -04:00
Niko Matsakis
af94b253be debug dump for interned struct tokens 2024-05-24 07:16:50 -04:00
Niko Matsakis
d6d522662c have tracked struct intern its own keys
Previously tracked structs relied on an
interned ingredient to intern their keys.
But really it has more complex logic than we
need. Simpler to just remove it and duplicate
the basic concept.
2024-05-24 07:16:50 -04:00
Niko Matsakis
4822013523 permit interned data to take 'db lifetime 2024-05-24 07:16:50 -04:00
Niko Matsakis
d190bebcac introduce helper functions
We'll need these for use with tracked functions
2024-05-24 07:16:50 -04:00
Niko Matsakis
97fc6a0920 rework interning to have a Configuration
This will permit GATs so that interned values
can carry lifetimes.
2024-05-24 07:16:50 -04:00
Niko Matsakis
54c9586b45 move interned-specific fns out of salsa struct
Salsa struct is already a grab-bag, best to keep
it to shared functionality.
2024-05-24 07:16:50 -04:00
Niko Matsakis
8ba6e606c0 generate configuration struct in salsa_struct
It will be shared between tracked structs and
interned structs.
2024-05-24 07:16:50 -04:00
Niko Matsakis
4f74037f41 pipe debug output through rustfmt
is there a nicer way to do this?!
2024-05-24 07:16:50 -04:00
Niko Matsakis
04e041b4a2 rework debugging to be more permanent 2024-05-24 07:16:50 -04:00
Niko Matsakis
fe4ff9816a support db lifetimes in fields 2024-05-24 07:16:50 -04:00
Niko Matsakis
a84777d5a7 permit <'db> on tracked struct
tracked structs with `'db` carry a pointer
and not an id.
2024-05-24 07:16:50 -04:00
Niko Matsakis
e95c8b21fb give fields a lifetime 2024-05-24 07:16:50 -04:00
Niko Matsakis
44a8a2f41c make fn input/value a GAT 2024-05-24 07:16:50 -04:00
Niko Matsakis
b050bd874a remove Key from Fn configuration
Just use salsa::Id for the most part.
2024-05-24 07:16:50 -04:00
Niko Matsakis
6e2647fa50 just take salsa::Id instead of id structs 2024-05-24 07:16:50 -04:00
Niko Matsakis
cb1a2bb75b Revert "WIP permit 'db on tracked struct definitions (opt)"
This reverts commit 43b1b8ef3f98213279b9d0768847603299162f1f.
2024-05-24 07:16:50 -04:00
Niko Matsakis
b6311d8102 WIP permit 'db on tracked struct definitions (opt) 2024-05-24 07:16:50 -04:00
Niko Matsakis
5ce5e3c374 track and assert struct ingredient indices
We need a cheap way to compute field indices.
2024-05-24 07:16:50 -04:00
Niko Matsakis
79d24e0ad7 allow (but don't test) lifetime parameters 2024-05-24 07:16:50 -04:00
Niko Matsakis
ea1d452143 create a struct_map that encapsulates access
The internal API is now based around providing
references to the `TrackedStructValue`.

Documenting the invariants led to one interesting
case, which is that we sometimes verify a tracked
struct as not having changed (and even create
`&`-ref to it!) but then re-execute the function
around it.

We now guarantee that, in this case, the data
does not change, even if it has leaked values.
This is required to ensure soundness.
Add a test case about it.
2024-05-24 07:16:47 -04:00
Niko Matsakis
20cb307301 give trait more info about lifetime relationships
In particular, the ingredient and the database
have the same lifetime.
This will be useful later for safety conditions.
2024-05-24 07:15:40 -04:00
Niko Matsakis
a32078153b separate marking the outputs as verified
There are 3 call-sites to this function:

* One of them has already marked the outputs
* One of them has no outputs
* The third does need to mark the outputs
2024-05-24 07:15:40 -04:00
Niko Matsakis
e24ace24eb return &TrackedStructValue<C> from new_struct
This is a step towards the goal of keep a pointer
in the structs themselves.
2024-05-24 07:15:40 -04:00
Niko Matsakis
4533cd9e4b adopt the Salsa 3.0 Update` trait
Right now, this doesn't change much except the
behavior in the event that `Eq` is not properly
implemented. In the future, it will enable
the use of references and slices and things.
2024-05-24 07:15:40 -04:00
Niko Matsakis
90597b18ab
remove stray eprintln 2024-04-12 04:57:41 -04:00
Niko Matsakis
82b672df3b allow various clippy lint groups 2024-04-05 05:48:11 -04:00
Niko Matsakis
f4a8ed650f update tracked struct created_at when validated
Fixes #484
2024-04-05 05:15:59 -04:00
Niko Matsakis
5d6f883b18 improve spans for inputs 2024-04-04 06:24:07 -04:00
Niko Matsakis
1acbf2b0d4 improve spans for getters, constructors
This helps the IDE support.
2024-04-04 06:14:31 -04:00
Niko Matsakis
ce2f78290a add FIXME 2024-04-03 06:33:17 -04:00
Niko Matsakis
9dfa84b693 improve doc comments 2024-04-03 06:30:31 -04:00
Niko Matsakis
fd15c3a600 support customizing the DebugWithDb impl 2024-04-03 06:23:43 -04:00
Niko Matsakis
389aa66bcf print all fields in debug() but ignore deps
In a previous PR we added the `include_all_fields`
parameter to `DebugWithDb` to allow it to
not create spurious dependencies.

This PR takes a different approach: we simply
ignore the dependencies created during debug
operations. This is risky as it can create
incorrect dependencies, but it is way more
convenient and seems like what users probably
want.

It also means that `DebugWithDb` has a simpler
signature that matches the `Debug` trait again,
which seems good to me.
2024-04-03 05:59:11 -04:00