about summary refs log tree commit diff
path: root/compiler/rustc_macros/src/serialize.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-08-17 08:51:52 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2023-08-18 16:50:41 +1000
commit34493047226477272354cd7ac413720d1a446f43 (patch)
tree07e7bc208cc9ec287e26434c1429b2ef0daaee75 /compiler/rustc_macros/src/serialize.rs
parent9167eea553d00a790c10ebc0a821e3fa1b13d93c (diff)
downloadrust-34493047226477272354cd7ac413720d1a446f43.tar.gz
rust-34493047226477272354cd7ac413720d1a446f43.zip
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.
Diffstat (limited to 'compiler/rustc_macros/src/serialize.rs')
-rw-r--r--compiler/rustc_macros/src/serialize.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs
index f1e7b8eb6c7..ba75517d7a6 100644
--- a/compiler/rustc_macros/src/serialize.rs
+++ b/compiler/rustc_macros/src/serialize.rs
@@ -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),
                 }
             }
         }