mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-13 00:40:22 +00:00
Fix a merge conflict
This commit is contained in:
parent
f2aff84b73
commit
b9bd1462cb
1 changed files with 1 additions and 21 deletions
|
@ -18,27 +18,7 @@ eprintln!("Expression = {:?}", expr.debug(db));
|
|||
|
||||
and get back the output you expect.
|
||||
|
||||
## Implementing the `DebugWithDb` trait
|
||||
|
||||
For now, unfortunately, you have to implement the `DebugWithDb` trait manually, as we do not provide a derive.
|
||||
|
||||
> You can find the tracking issue for addressing this [here][debug_with_db_issue].
|
||||
|
||||
This is tedious but not difficult. Here is an example of implementing the trait for `Expression`:
|
||||
|
||||
```rust
|
||||
{{#include ../../../calc-example/calc/src/ir.rs:expression_debug_impl}}
|
||||
```
|
||||
|
||||
Some things to note:
|
||||
|
||||
- The `data` method gives access to the full enum from the database.
|
||||
- The [`Formatter`] methods (e.g., [`debug_tuple`]) can be used to provide consistent output.
|
||||
- When printing the value of a field, use `.field(&a.debug(db))` for fields that are themselves interned or entities, and use `.field(&a)` for fields that just implement the ordinary `Debug` trait.
|
||||
|
||||
[debug_with_db_issue]: https://github.com/salsa-rs/salsa/issues/317
|
||||
[`debug_tuple`]: https://doc.rust-lang.org/std/fmt/struct.Formatter.html#method.debug_tuple
|
||||
[`formatter`]: https://doc.rust-lang.org/std/fmt/struct.Formatter.html#
|
||||
The `DebugWithDb` trait is automatically derived for all `#[input]`, `#[interned]`, and `#[tracked]` structs.
|
||||
|
||||
## Forwarding to the ordinary `Debug` trait
|
||||
|
||||
|
|
Loading…
Reference in a new issue