paritytech / paritytech/parity-common

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

Open
#604 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

F2-bug
Dominant language
Rust
Stars
311
Forks
245
PR merge metrics
No merged PRs in 30d

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the examples using the rlp_derive::RlpEncodable and RlpEncodableWrapper entry points, then trace the generated code reported at src/scrubbed.rs:64. Compare handling of nested Vec types and allocator parameters; done means both derive examples compile without the reported generic-argument errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.