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.
First step towards the new tracked struct design.
SUBTLE: This is actually broken if the `#[id]`
fields have a broken hash. We'll fix that in the
next commit and add a test.
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.
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>
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>