From c931c13ddeeeeab5239e3c82f58195247fabf5b7 Mon Sep 17 00:00:00 2001 From: Cameron Mulhern Date: Sat, 22 Mar 2025 13:04:28 -0400 Subject: [PATCH 1/5] Fixes checks for serde features in flexbuffers crate --- rust/flexbuffers/src/builder/ser.rs | 2 +- rust/flexbuffers/src/reader/de.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/flexbuffers/src/builder/ser.rs b/rust/flexbuffers/src/builder/ser.rs index 2533a404ac4..3ecf15de807 100644 --- a/rust/flexbuffers/src/builder/ser.rs +++ b/rust/flexbuffers/src/builder/ser.rs @@ -216,7 +216,7 @@ impl<'a> ser::Serializer for &'a mut FlexbufferSerializer { type Ok = (); type Error = Error; fn is_human_readable(&self) -> bool { - cfg!(serialize_human_readable) + cfg!(feature = "serialize_human_readable") } fn serialize_bool(self, v: bool) -> Result { self.builder.push(v); diff --git a/rust/flexbuffers/src/reader/de.rs b/rust/flexbuffers/src/reader/de.rs index 6213916ba6d..348c3f18413 100644 --- a/rust/flexbuffers/src/reader/de.rs +++ b/rust/flexbuffers/src/reader/de.rs @@ -160,7 +160,7 @@ impl<'de> VariantAccess<'de> for Reader<&'de [u8]> { impl<'de> Deserializer<'de> for Reader<&'de [u8]> { type Error = DeserializationError; fn is_human_readable(&self) -> bool { - cfg!(deserialize_human_readable) + cfg!(feature = "deserialize_human_readable") } fn deserialize_any(self, visitor: V) -> Result From 038593d923cf31a38bdfdf8867d0236e1e5e00fc Mon Sep 17 00:00:00 2001 From: Cameron Mulhern Date: Sat, 22 Mar 2025 13:05:17 -0400 Subject: [PATCH 2/5] Removes unused MapReaderIndexer use statement --- rust/flexbuffers/src/reader/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/flexbuffers/src/reader/mod.rs b/rust/flexbuffers/src/reader/mod.rs index ddf495145c2..5035dea6c6f 100644 --- a/rust/flexbuffers/src/reader/mod.rs +++ b/rust/flexbuffers/src/reader/mod.rs @@ -26,7 +26,7 @@ mod serialize; mod vector; pub use de::DeserializationError; pub use iter::ReaderIterator; -pub use map::{MapReader, MapReaderIndexer}; +pub use map::MapReader; pub use vector::VectorReader; /// All the possible errors when reading a flexbuffer. From 06f361f126e2e443740288c954bac7f00fd32742 Mon Sep 17 00:00:00 2001 From: Cameron Mulhern Date: Sat, 22 Mar 2025 13:07:39 -0400 Subject: [PATCH 3/5] Fixes warning about nightly cfg usage Enabling a cfg attribute through cargo::rustc-cfg in build.rs should be coupled with a cargo::rust-check-cfg value so that the compiler knows about the custom cfg. See: https://doc.rust-lang.org/rustc/check-cfg/cargo-specifics.html#cargorustc-check-cfg-for-buildrsbuild-script. --- rust/flatbuffers/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/flatbuffers/build.rs b/rust/flatbuffers/build.rs index c13ed1da485..ed82da90992 100644 --- a/rust/flatbuffers/build.rs +++ b/rust/flatbuffers/build.rs @@ -1,4 +1,4 @@ -use rustc_version::{version_meta, Channel}; +use rustc_version::{Channel, version_meta}; fn main() { let version_meta = version_meta().unwrap(); @@ -6,6 +6,7 @@ fn main() { // To use nightly features we declare this and then we can use // #[cfg(nightly)] // for nightly only features + println!("cargo:rustc-check-cfg=cfg(nightly)"); if version_meta.channel == Channel::Nightly { println!("cargo:rustc-cfg=nightly") } From 1612812c3402351f0d13d70b63427e82d89c473b Mon Sep 17 00:00:00 2001 From: Cameron Mulhern Date: Sat, 22 Mar 2025 13:10:11 -0400 Subject: [PATCH 4/5] Migrates usage of deprecated float constants This update fixes a compiler warning from use of the old constants. Constants like EPSILON are now directly on the float primitives (e.g. f32::EPSILON) rather than in the f32 module (std::f32::EPSILON). The new constants have existed since 1.43.0, which appears to be below the MSRV for the flatbuffers crate. --- tests/rust_usage_test/bin/flatbuffers_alloc_check.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs b/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs index bcc9dd3c8b9..bffb30074f8 100644 --- a/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs +++ b/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs @@ -142,10 +142,10 @@ fn main() { // We know the bits should be exactly equal here but compilers may // optimize floats in subtle ways so we're playing it safe and using // epsilon comparison - assert!((pos.x() - 1.0f32).abs() < std::f32::EPSILON); - assert!((pos.y() - 2.0f32).abs() < std::f32::EPSILON); - assert!((pos.z() - 3.0f32).abs() < std::f32::EPSILON); - assert!((pos.test1() - 3.0f64).abs() < std::f64::EPSILON); + assert!((pos.x() - 1.0f32).abs() < f32::EPSILON); + assert!((pos.y() - 2.0f32).abs() < f32::EPSILON); + assert!((pos.z() - 3.0f32).abs() < f32::EPSILON); + assert!((pos.test1() - 3.0f64).abs() < f64::EPSILON); assert_eq!(pos.test2(), my_game::example::Color::Green); let pos_test3 = pos.test3(); assert_eq!(pos_test3.a(), 5i16); From 8293acc60252425d8346a0998efd3bf833133bbe Mon Sep 17 00:00:00 2001 From: Cameron Mulhern Date: Sat, 22 Mar 2025 13:30:14 -0400 Subject: [PATCH 5/5] Fixes incorrect key in flatbuffers Cargo.toml The old code was using package.rust, which triggered a warning about an unused key: warning: flatbuffers/rust/flatbuffers/Cargo.toml: unused manifest key: package.rust The correct key for specifying MSRV is rust-version. See: https://doc.rust-lang.org/cargo/reference/rust-version.html#rust-version. --- rust/flatbuffers/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/flatbuffers/Cargo.toml b/rust/flatbuffers/Cargo.toml index 1cc62bdae7a..826526d1e46 100644 --- a/rust/flatbuffers/Cargo.toml +++ b/rust/flatbuffers/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://google.github.io/flatbuffers/" repository = "https://github.com/google/flatbuffers" keywords = ["flatbuffers", "serialization", "zero-copy"] categories = ["encoding", "data-structures", "memory-management"] -rust = "1.51" +rust-version = "1.51" [features] default = ["std"]