Skip to content

Commit f794871

Browse files
committed
Fix test for #580 which was incorrect and fix the deserializer fix for it
1 parent c79ad58 commit f794871

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/de/map.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -883,17 +883,16 @@ where
883883
}
884884

885885
/// Forwards deserialization of the inner type. Always calls [`Visitor::visit_newtype_struct`]
886-
/// with the [`SimpleTypeDeserializer`].
886+
/// with this deserializer.
887887
fn deserialize_newtype_struct<V>(
888-
mut self,
888+
self,
889889
_name: &'static str,
890890
visitor: V,
891891
) -> Result<V::Value, Self::Error>
892892
where
893893
V: Visitor<'de>,
894894
{
895-
let text = self.read_string()?;
896-
visitor.visit_newtype_struct(SimpleTypeDeserializer::from_text(text))
895+
visitor.visit_newtype_struct(self)
897896
}
898897

899898
/// This method deserializes a sequence inside of element that itself is a

tests/serde-issues.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use pretty_assertions::assert_eq;
66
use quick_xml::de::from_str;
77
use quick_xml::se::{to_string, to_string_with_root};
8-
use serde::{Deserialize, Deserializer, Serialize};
8+
use serde::de::{Deserializer, IgnoredAny};
9+
use serde::{Deserialize, Serialize};
910
use std::collections::HashMap;
1011

1112
/// Regression tests for https://github.com/tafia/quick-xml/issues/252.
@@ -393,10 +394,13 @@ fn issue580() {
393394
#[derive(Debug, PartialEq, Eq)]
394395
struct Item;
395396
impl Item {
396-
fn parse<'de, D>(_deserializer: D) -> Result<Self, D::Error>
397+
fn parse<'de, D>(deserializer: D) -> Result<Self, D::Error>
397398
where
398399
D: Deserializer<'de>,
399400
{
401+
// We should consume something from the deserializer, otherwise this
402+
// leads to infinity loop
403+
IgnoredAny::deserialize(deserializer)?;
400404
Ok(Item)
401405
}
402406
}

0 commit comments

Comments
 (0)