Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive struct gives: overflow evaluating the requirement SliceReader: Sized #467

Closed
5225225 opened this issue Jan 8, 2022 · 0 comments · Fixed by #470
Closed

recursive struct gives: overflow evaluating the requirement SliceReader: Sized #467

5225225 opened this issue Jan 8, 2022 · 0 comments · Fixed by #470

Comments

@5225225
Copy link
Contributor

5225225 commented Jan 8, 2022

use std::collections::BTreeMap;

#[derive(bincode::Decode)]
struct AllTypes(BTreeMap<u8, AllTypes>);

fn main() {
    let result: Result<(AllTypes, _), _> = bincode::decode_from_slice(
        &[],
        bincode::config::Configuration::standard().with_limit::<1024>(),
    );
}
[dependencies]
bincode = "2.0.0-beta.0"
error[E0275]: overflow evaluating the requirement `SliceReader: Sized`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`scratchhM619rEHl`)
  = note: required because of the requirements on the impl of `Decoder` for `DecoderImpl<SliceReader, Configuration<LittleEndian, Varint, SkipFixedArrayLength, Limit<1024_usize>>>`
  = note: 128 redundant requirements hidden
  = note: required because of the requirements on the impl of `Decoder` for `&mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut DecoderImpl<SliceReader, Configuration<LittleEndian, Varint, SkipFixedArrayLength, Limit<1024_usize>>>`

This code might be wrong, but is there any way to detect it earlier?

VictorKoenders added a commit that referenced this issue Jan 11, 2022
* Switched Decode and BorrowDecode to take &mut D, fixes #467

* I didn't forget to run cargo fmt, you did
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant