Debian Codegraph @

gcc/testsuite/rust/execute/torture/operator_overload_12.rs

raw
1 // { dg-output "1\r*\n" }
2 // { dg-additional-options "-w" }
3 extern "C" {
4 fn printf(s: *const i8, ...);
5 }
6
7 #[lang = "sized"]
8 pub trait Sized {}
9
10 #[lang = "bitand_assign"]
11 pub trait BitAndAssign<Rhs = Self> {
12 fn bitand_assign(&mut self, rhs: Rhs);
13 }
14
15 impl BitAndAssign for i32 {
16 fn bitand_assign(&mut self, other: i32) {
17 *self &= other;
18
19 unsafe {
20 let a = "%i\n\0";
21 let b = a as *const str;
22 let c = b as *const i8;
23
24 printf(c, *self);
25 }
26 }
27 }
28
29 fn main() -> i32 {
30 let mut a = 1;
31 a &= 1;
32
33 0
34 }