Skip to content

Commit 3449304

Browse files
committed
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.
1 parent 9167eea commit 3449304

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_macros/src/serialize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ fn decodable_body(
5959
})
6060
.collect();
6161
let message = format!(
62-
"invalid enum variant tag while decoding `{}`, expected 0..{}",
62+
"invalid enum variant tag while decoding `{}`, expected 0..{}, actual {{}}",
6363
ty_name,
6464
variants.len()
6565
);
6666
quote! {
6767
match ::rustc_serialize::Decoder::read_usize(__decoder) {
6868
#match_inner
69-
_ => panic!(#message),
69+
n => panic!(#message, n),
7070
}
7171
}
7272
}

0 commit comments

Comments
 (0)