Is there a way to see generated code for `derive` attributes?

The available doc does not give much details about the code generated through the derive attribute. In fact the spec only talks about deriving two traits (PartialEq and Clone).

My understanding is that derive is handled in an ad hoc fashion inside the compiler. So yes, a proper specification would be of great help.

My question is more pragmatic. In the mean time do you know of any any way to get the generated code? For example through a flag of rustc.

1 Like

I think you can get the expanded output by

rustc <source file> -Z unstable-options --pretty=expanded
2 Likes

Thanks! The code is not so "pretty" with everything expanded but it works really well and does answer my questions about derive.