Remove conversion from empty seq to unit struct

This commit is contained in:
David Tolnay 2017-04-09 13:08:05 -07:00
parent cc933b9cdb
commit 1986c17052
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 7 additions and 15 deletions

View File

@ -168,13 +168,6 @@ fn deserialize_unit_struct(ident: &syn::Ident, item_attrs: &attr::Item) -> Fragm
{
_serde::export::Ok(#ident)
}
#[inline]
fn visit_seq<__V>(self, _: __V) -> _serde::export::Result<#ident, __V::Error>
where __V: _serde::de::SeqVisitor<'de>
{
_serde::export::Ok(#ident)
}
}
_serde::Deserializer::deserialize_unit_struct(__deserializer, #type_name, __Visitor)

View File

@ -242,14 +242,6 @@ declare_tests! {
UnitStruct => &[
Token::UnitStruct("UnitStruct"),
],
UnitStruct => &[
Token::Seq(Some(0)),
Token::SeqEnd,
],
UnitStruct => &[
Token::Seq(None),
Token::SeqEnd,
],
}
test_newtype_struct {
NewtypeStruct(1) => &[
@ -1036,4 +1028,11 @@ declare_error_tests! {
],
Error::Message("invalid type: floating point `0`, expected isize".into()),
}
test_unit_struct_from_seq<UnitStruct> {
&[
Token::Seq(Some(0)),
Token::SeqEnd,
],
Error::Message("invalid type: sequence, expected unit struct UnitStruct".into()),
}
}