holochain / holochain-rust

DEPRECATED. The Holochain framework implemented in rust with a redux style internal state-model.
GNU General Public License v3.0
1.12k stars 267 forks source link

`validate` in hdk-rust macro gives obscure unhelpful error messages #589

Open maackle opened 5 years ago

maackle commented 5 years ago

It's hard to debug the validation function, errors often result in the entire macro invocation failing with an obscure and incorrect error:

the size for values of type `dyn std::ops::FnMut(std::string::String, hdk::ValidationData) -> std::result::Result<(), std::string::String> + std::marker::Sync` cannot be known at compilation time

doesn't have a size known at compile-time

help: the trait `std::marker::Sized` is not implemented for `dyn std::ops::FnMut(std::string::String, hdk::ValidationData) -> std::result::Result<(), std::string::String> + std::marker::Sync`

I've resorted to writing a fn with the same signature as the macro closure requires, and then just calling the function from the macro as a one-liner, so I can get normal error messages.

ddd-mtl commented 5 years ago

Yep, welcome to macro hell :)