Skip to content

BorshDeserializeAsync derive for recursive structs fails to compile #343

@dj8yfo

Description

@dj8yfo

This issue is marked inactive as it depends on unmerged code in #337

#[derive(Clone, BorshDeserializeAsync)]
struct CRecA {
    a: String,
    b: Box<CRecA>,
}

derive of BorshSerializeAsync is fine, but deser fails with error:

error[E0391]: cycle detected when computing type of `compile_derives::async_derives::test_recursive_structs::<impl at borsh/tests/compile_derives/async_derives/test_recursive_structs.rs:17:17: 17:38>::{synthetic#0}`
  --> borsh/tests/compile_derives/async_derives/test_recursive_structs.rs:17:17
   |
17 | #[derive(Clone, BorshDeserializeAsync)]
   |                 ^^^^^^^^^^^^^^^^^^^^^
   |
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
  --> borsh/tests/compile_derives/async_derives/test_recursive_structs.rs:17:17
   |
17 | #[derive(Clone, BorshDeserializeAsync)]
   |                 ^^^^^^^^^^^^^^^^^^^^^
   = note: ...which again requires computing type of `compile_derives::async_derives::test_recursive_structs::<impl at borsh/tests/compile_derives/async_derives/test_recursive_structs.rs:17:17: 17:38>::{synthetic#0}`, completing the cycle
note: cycle used when checking that `compile_derives::async_derives::test_recursive_structs::<impl at borsh/tests/compile_derives/async_derives/test_recursive_structs.rs:17:17: 17:38>` is well-formed
  --> borsh/tests/compile_derives/async_derives/test_recursive_structs.rs:17:17
   |
17 | #[derive(Clone, BorshDeserializeAsync)]
   |                 ^^^^^^^^^^^^^^^^^^^^^
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
   = note: this error originates in the derive macro `BorshDeserializeAsync` (in Nightly builds, run with -Z macro-backtrace for more info)
                                                                                                                                                                        
For more information about this error, try `rustc --explain E0391`.

a workaround with manual implementation is mentioned in #337 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions