derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Optionally have trait methods use `track_caller` to push panic information to the caller

Open zesterer opened this issue 1 year ago • 5 comments
trafficstars

Hopefully the issue title is fairly self-explanatory. Is this a desirable feature? This could take the form of an optional track_caller feature.

zesterer avatar May 25 '24 17:05 zesterer

For which derives are you interested in this specifically?

JelteF avatar May 25 '24 17:05 JelteF

Specifically, the operator traits (add, mul, etc.). I've got a client type that often experiences overflows in those operators, and no ability to unwind the stack on my target platform, so I end up with panic messages that point to the middle of the derive code rather than the use location.

zesterer avatar May 27 '24 18:05 zesterer

Ah, okay yeah that does seem annoying. I think for operators it indeed makes sense to add track_caller. Could you send a PR for that?

JelteF avatar May 27 '24 19:05 JelteF

To clarify I don't think this needs to be an optional feature, but can simply be done always for add and mul derives.

JelteF avatar May 28 '24 00:05 JelteF

I'm not too familiar with the codebase, is there some specific location that's best to start implementing this?

zesterer avatar May 28 '24 09:05 zesterer

Thanks so much for implementing this! This will make debugging fixed-point ops on embedded platforms without stack traces infinitely easier!

zesterer avatar Jul 07 '24 14:07 zesterer