parity-common icon indicating copy to clipboard operation
parity-common copied to clipboard

[rlp-derive] encode for Vec<Vec<T>> has type errors

Open skylerqpq opened this issue 3 years ago • 0 comments

repro example

#[derive(rlp_derive::RlpEncodable)]
struct DoubleVec {
    data: Vec<Vec<u8>>,
}

// Just to note that this also fails.
#[derive(rlp_derive::RlpEncodableWrapper)]
struct DoubleVec2 {
    data: Vec<Vec<u8>>,
}

Expected outcome

This compiles

Actual result

error[E0107]: missing generics for struct `Vec`
   --> src/scrubbed.rs:Line:Column
    |
64  |     data: Vec<Vec<u8>>,
    |               ^^^ expected at least 1 generic argument
    |
note: struct defined here, with at least 1 generic parameter: `T`
   --> /Users/sross/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:398:12
    |
398 | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
    |            ^^^ -
help: add missing generic argument
    |
64  |     data: Vec<Vec<T><u8>>,
    |               ~~~~~~

Additionally, the assumption in the derive code about Vec only having one type parameter is false (the allocator API adds a second type param A)

skylerqpq avatar Nov 30 '21 20:11 skylerqpq