Repository: tafia/quick-xml
Pull request #745 (2024-05-20 09:08:35)

Add .rustfmt.toml, specify edition = "2021"
There are two common ways to run rustfmt:

  $ cargo fmt
  $ rustfmt

In the first case, Cargo.toml will be used to configure rustfmt. In the second case, Cargo.toml won't be used and rustfmt will assume certain defaults. Specifically, it will default to Rust 2015 edition which for the quick-xml project results in errors like:

[E0670]: async fn is not permitted in Rust 2015

One of the scenarios when rustfmt is called instead of cargo fmt is "rustic" mode in emacs. The developers of "rustic" mode ask to configure .rustfmt.toml:

See: https://github.com/brotzeit/rustic?tab=readme-ov-file#edition-2018


Patch:
diff --git a/.rustfmt.toml b/.rustfmt.toml
new file mode 100644
index 0000000..3a26366
--- /dev/null
+++ b/.rustfmt.toml
@@ -0,0 +1,1 @@
+edition = "2021"
diff --git a/Changelog.md b/Changelog.md
index 9aecbb9..666bcf8 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -40,7 +40,6 @@ to get an offset of the error position. For `SyntaxError`s the range
 - [#684]: Fix incorrect position reported for `Error::IllFormed(DoubleHyphenInComment)`.
 - [#684]: Fix incorrect position reported for `Error::IllFormed(MissingDoctypeName)`.
 - [#704]: Fix empty tags with attributes not being expanded when `expand_empty_elements` is set to true.
-- [#683]: Use local tag name when check tag name against possible names for field.
 
 ### Misc Changes
 
@@ -73,7 +72,6 @@ to get an offset of the error position. For `SyntaxError`s the range
 [#629]: https://github.com/tafia/quick-xml/issues/629
 [#675]: https://github.com/tafia/quick-xml/pull/675
 [#677]: https://github.com/tafia/quick-xml/pull/677
-[#683]: https://github.com/tafia/quick-xml/issues/683
 [#684]: https://github.com/tafia/quick-xml/pull/684
 [#689]: https://github.com/tafia/quick-xml/pull/689
 [#704]: https://github.com/tafia/quick-xml/pull/704
diff --git a/src/de/map.rs b/src/de/map.rs
index 3989a64..64ae6a6 100644
--- a/src/de/map.rs
+++ b/src/de/map.rs
@@ -789,7 +789,7 @@ fn not_in(
     start: &BytesStart,
     decoder: Decoder,
 ) -> Result<bool, DeError> {
-    let tag = decoder.decode(start.local_name().into_inner())?;
+    let tag = decoder.decode(start.name().into_inner())?;
 
     Ok(fields.iter().all(|&field| field != tag.as_ref()))
 }
@@ -1181,8 +1181,6 @@ where
 
 #[test]
 fn test_not_in() {
-    use pretty_assertions::assert_eq;
-
     let tag = BytesStart::new("tag");
 
     assert_eq!(not_in(&[], &tag, Decoder::utf8()).unwrap(), true);
@@ -1194,18 +1192,4 @@ fn test_not_in() {
         not_in(&["some", "tag", "included"], &tag, Decoder::utf8()).unwrap(),
         false
     );
-
-    let tag_ns = BytesStart::new("ns1:tag");
-    assert_eq!(
-        not_in(&["no", "such", "tags"], &tag_ns, Decoder::utf8()).unwrap(),
-        true
-    );
-    assert_eq!(
-        not_in(&["some", "tag", "included"], &tag_ns, Decoder::utf8()).unwrap(),
-        false
-    );
-    assert_eq!(
-        not_in(&["some", "namespace", "ns1:tag"], &tag_ns, Decoder::utf8()).unwrap(),
-        true
-    );
 }


Test patch:
diff --git a/tests/serde-issues.rs b/tests/serde-issues.rs
index 2726e45..a3e95b9 100644
--- a/tests/serde-issues.rs
+++ b/tests/serde-issues.rs
@@ -462,35 +462,3 @@ fn issue580() {
         }
     );
 }
-
-/// Regression test for https://github.com/tafia/quick-xml/issues/683.
-#[test]
-fn issue683() {
-    #[derive(Deserialize, Debug, PartialEq)]
-    enum ScheduleLocation {
-        #[serde(rename = "DT")]
-        Destination,
-    }
-
-    #[derive(Deserialize, Debug, PartialEq)]
-    #[allow(non_snake_case)]
-    struct Schedule {
-        cancelReason: Option<u32>,
-        #[serde(rename = "$value")]
-        locations: Vec<ScheduleLocation>,
-    }
-    let xml = r#"
-        <schedule xmlns:ns2="http://www.thalesgroup.com/rtti/PushPort/Schedules/v3">
-            <ns2:DT/>
-            <ns2:cancelReason>918</ns2:cancelReason>
-        </schedule>"#;
-    let result = quick_xml::de::from_str::<Schedule>(xml);
-    dbg!(&result);
-    assert_eq!(
-        result.unwrap(),
-        Schedule {
-            cancelReason: Some(918),
-            locations: vec![ScheduleLocation::Destination],
-        }
-    );
-}