mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Make enum decoding errors more informative.
By printing the actual value, as long as the expected range. I found this helpful when I encountered one of these errors.
This commit is contained in:
parent
9167eea553
commit
3449304722
@ -59,14 +59,14 @@ fn decodable_body(
|
||||
})
|
||||
.collect();
|
||||
let message = format!(
|
||||
"invalid enum variant tag while decoding `{}`, expected 0..{}",
|
||||
"invalid enum variant tag while decoding `{}`, expected 0..{}, actual {{}}",
|
||||
ty_name,
|
||||
variants.len()
|
||||
);
|
||||
quote! {
|
||||
match ::rustc_serialize::Decoder::read_usize(__decoder) {
|
||||
#match_inner
|
||||
_ => panic!(#message),
|
||||
n => panic!(#message, n),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user