Fix expected struct sizes for nightly optimizations (no more CI warnings)

xmppftw created

Change summary

parsers/Cargo.toml        |  3 +++
parsers/build.rs          | 12 ++++++++++++
parsers/src/disco.rs      |  3 +++
parsers/src/jid_prep.rs   |  3 +++
parsers/src/jingle_s5b.rs |  3 +++
parsers/src/stanza_id.rs  |  3 +++
6 files changed, 27 insertions(+)

Detailed changes

parsers/Cargo.toml 🔗

@@ -24,6 +24,9 @@ sha3 = "0.10"
 blake2 = "0.10.4"
 chrono = { version = "0.4.5", default-features = false, features = ["std"] }
 
+[build-dependencies]
+rustc_version = "0.4"
+
 [features]
 # Build xmpp-parsers to make components instead of clients.
 component = []

parsers/build.rs 🔗

@@ -0,0 +1,12 @@
+use rustc_version::{version_meta, Channel};
+
+fn main() {
+    let version = version_meta().unwrap();
+
+    match version.channel {
+        Channel::Nightly => {
+            println!("cargo:rustc-cfg=rustc_nightly");
+        }
+        _ => {}
+    }
+}

parsers/src/disco.rs 🔗

@@ -254,6 +254,9 @@ mod tests {
         assert_size!(DiscoInfoQuery, 24);
         assert_size!(DiscoInfoResult, 96);
 
+        #[cfg(rustc_nightly)]
+        assert_size!(Item, 120);
+        #[cfg(not(rustc_nightly))]
         assert_size!(Item, 128);
         assert_size!(DiscoItemsQuery, 24);
         assert_size!(DiscoItemsResult, 48);

parsers/src/jid_prep.rs 🔗

@@ -55,6 +55,9 @@ mod tests {
     #[test]
     fn test_size() {
         assert_size!(JidPrepQuery, 24);
+        #[cfg(rustc_nightly)]
+        assert_size!(JidPrepResponse, 72);
+        #[cfg(not(rustc_nightly))]
         assert_size!(JidPrepResponse, 80);
     }
 

parsers/src/jingle_s5b.rs 🔗

@@ -298,6 +298,9 @@ mod tests {
         assert_size!(Mode, 1);
         assert_size!(CandidateId, 24);
         assert_size!(StreamId, 24);
+        #[cfg(rustc_nightly)]
+        assert_size!(Candidate, 128);
+        #[cfg(not(rustc_nightly))]
         assert_size!(Candidate, 136);
         assert_size!(TransportPayload, 32);
         assert_size!(Transport, 88);

parsers/src/stanza_id.rs 🔗

@@ -52,6 +52,9 @@ mod tests {
     #[cfg(target_pointer_width = "64")]
     #[test]
     fn test_size() {
+        #[cfg(rustc_nightly)]
+        assert_size!(StanzaId, 96);
+        #[cfg(not(rustc_nightly))]
         assert_size!(StanzaId, 104);
         assert_size!(OriginId, 24);
     }