Thread 'tests::save_candid' panicked at 'Cannot use Func directly

I use the famous workaround to generate automatically the did files from Rust code (see for example here in Juno).

After upgrading to last ic-cdk = "0.10.0" and candid = "0.9.1", I get following error when I generate the types. Any cluse what’s the issue?

running 1 test
test tests::save_candid … FAILED

failures:

---- tests::save_candid stdout ----
thread ‘tests::save_candid’ panicked at ‘Cannot use Func directly. Use define_function! macro instead.’, /Users/daviddalbusco/.cargo/registry/src/github.com-1ecc6299db9ec823/candid-0.9.1/src/types/reference.rs:83:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

failures:
tests::save_candid

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass -p satellite --lib

We changed the way to define function types.

Following code in ic-cdk might help you:

1 Like

Still got one issue but, almost there. As soon as I got the solution will clean it and share it properly.

Finally, I’ve managed to solve all the issues thanks to the help provided by @lwshang and @chenyan (:pray:). If anyone else is interested in migrating the ic_cdk to latest version while still generating the Candid files automatically for the Rust code, I’ve documented my entire migration process in the form of a blog post. Check it out!

ps: also crossposted on my website in case you don’t have a medium account.

3 Likes