From 8e8694261be764a0a4fdac5bafad6b4e4be406b2 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 19 Jun 2017 20:21:52 -0700 Subject: [PATCH] Fix identifier deserialization from non-u32 Closes #962 --- serde_derive/src/de.rs | 4 ++-- test_suite/tests/test_identifier.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index 20ccb696..741baec7 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -1387,10 +1387,10 @@ fn deserialize_identifier( }; let visit_index = if is_variant { - let variant_indices = 0u32..; + let variant_indices = 0u64..; let fallthrough_msg = format!("variant index 0 <= i < {}", fields.len()); let visit_index = quote! { - fn visit_u32<__E>(self, __value: u32) -> _serde::export::Result + fn visit_u64<__E>(self, __value: u64) -> _serde::export::Result where __E: _serde::de::Error { match __value { diff --git a/test_suite/tests/test_identifier.rs b/test_suite/tests/test_identifier.rs index 76f1cffa..83a0d3b1 100644 --- a/test_suite/tests/test_identifier.rs +++ b/test_suite/tests/test_identifier.rs @@ -23,7 +23,10 @@ fn test_variant_identifier() { Bbb, } + assert_de_tokens(&V::Aaa, &[Token::U8(0)]); + assert_de_tokens(&V::Aaa, &[Token::U16(0)]); assert_de_tokens(&V::Aaa, &[Token::U32(0)]); + assert_de_tokens(&V::Aaa, &[Token::U64(0)]); assert_de_tokens(&V::Aaa, &[Token::Str("Aaa")]); assert_de_tokens(&V::Aaa, &[Token::Bytes(b"Aaa")]); }