Commit c5974346d7 for qemu.org

commit c5974346d7a7300f5350ccf7af8d61996d9bda6a
Author: Nguyen Dinh Phi <phind.uet@gmail.com>
Date:   Mon Aug 3 01:03:44 2026 +0800

    rust/bits: Align SubAssign behavior with Sub

    Update SubAssign to perform a bit-clear operation instead of arithmetic
    subtraction, matching the behavior of Sub.

    Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
    Link: https://lore.kernel.org/r/20260802170346.3493821-2-phind.uet@gmail.com
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

diff --git a/rust/bits/src/lib.rs b/rust/bits/src/lib.rs
index d1141f7c88..60b63f969d 100644
--- a/rust/bits/src/lib.rs
+++ b/rust/bits/src/lib.rs
@@ -320,7 +320,7 @@ fn sub(self, rhs: $struct_name) -> Self::Output {

         impl ::std::ops::SubAssign<$struct_name> for $struct_name {
             fn sub_assign(&mut self, rhs: $struct_name) {
-                self.0 = self.0 - rhs.0
+                self.0 &= !rhs.0
             }
         }

@@ -443,4 +443,11 @@ pub fn test_xor() {
             InterruptMask::OE | InterruptMask::PE | InterruptMask::FE
         );
     }
+
+    #[test]
+    pub fn test_sub_assign() {
+        let mut op1 = InterruptMask::E;
+        op1 -= InterruptMask::RI;
+        assert_eq!(op1, InterruptMask::E - InterruptMask::RI);
+    }
 }