Closed ijackson closed 8 months ago
A field named builder
goes wrong too:
error[E0308]: mismatched types
--> src/main.rs:6:15
|
3 | #[derive(Educe)]
| ----- arguments to this method are incorrect
...
6 | Variant { builder: i32 },
| ^^^^^^^ expected `&dyn Debug`, found `DebugStruct<'_, '_>`
|
= note: expected reference `&dyn Debug`
found struct `DebugStruct<'_, '_>`
If DebugStruct
implemented Debug
this would compile and produce wrong output...
Thanks for your report!
YW. Another way to fix it that wouldn't involve pasting identifiers:
v @ Self::Variant { .. } => {
let mut builder = f.debug_struct("Variant");
builder.field("f", &v.f);
One way to produce a bizarre error:
Actual output:
Expected output: it compiles.
The reason is that the expansion looks like this (excerpt from cargo expand):
So
f
was rebound by the pattern.IMO the correct way to fix this is to bind each field to a local variable with a prefix:
This used to work in educe 0.4