Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Deserialization failure results in panic #101

Closed
WiSaGaN opened this issue Sep 3, 2018 · 1 comment
Closed

Deserialization failure results in panic #101

WiSaGaN opened this issue Sep 3, 2018 · 1 comment
Labels

Comments

@WiSaGaN
Copy link

WiSaGaN commented Sep 3, 2018

I expect de-serialization failure will result in returning error, but it seems not the case for program below:

#[macro_use]
extern crate serde;
extern crate serde_yaml;

#[derive(Deserialize)]
#[derive(Debug)]
pub struct Foo {
    pub foo: [(); 1],
}

fn main() {
    let result: serde_yaml::Result<Foo> = serde_yaml::from_str("foo:\n");
    println!("{:?}", result);
}

Running this using stable 1.28.0 will result in

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Message("invalid type: unit value, expected an array of length 1", None)', libcore/result.rs:945:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

It appears this is the offending line.

@WiSaGaN WiSaGaN changed the title Deserialization results in panic Deserialization failure results in panic Sep 3, 2018
@dtolnay dtolnay added the bug label Sep 3, 2018
@dtolnay
Copy link
Owner

dtolnay commented Sep 3, 2018

Thanks! Fixed in 0.8.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants