An experimental Rust nightly feature `get_set_bit` introduces a `bit()`
method on integer types which checks whether a specific bit is set. This
clashes with QEMU's `IntegerExt::bit()` associated function which
returns an integer with one particular bit set.

While the `get_set_bit` feature has no planned stabilization date yet,
this is reported as a `unstable_name_collisions` warning when compiling
with the `strict_rust_lints` option, and warnings are turned into errors.
Renaming `IntegerExt::bit()` to `IntegerExt::single_bit()` prevents this.

Signed-off-by: Samuel Tardieu <[email protected]>
---
 rust/common/src/bitops.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/common/src/bitops.rs b/rust/common/src/bitops.rs
index 06c78c3b8a..a0aff75d76 100644
--- a/rust/common/src/bitops.rs
+++ b/rust/common/src/bitops.rs
@@ -34,7 +34,7 @@ pub trait IntegerExt:
 
     #[inline]
     #[must_use]
-    fn bit(start: u32) -> Self
+    fn single_bit(start: u32) -> Self
     {
         debug_assert!(start < Self::BITS);
 
@@ -105,9 +105,9 @@ fn test_extract() {
     }
 
     #[test]
-    fn test_bit() {
-        assert_eq!(u8::bit(7), 128);
-        assert_eq!(u32::bit(16), 0x10000);
+    fn test_single_bit() {
+        assert_eq!(u8::single_bit(7), 128);
+        assert_eq!(u32::single_bit(16), 0x10000);
     }
 
     #[test]

---
base-commit: e9fa1f66f0d47c74b6766e1b8b87ad7c2a9394d5
change-id: 20261114-rust-single-bit-60366e5998ff

Best regards,
--  
Samuel Tardieu <[email protected]>


Reply via email to