Debian Codegraph @

gcc/testsuite/rust/execute/torture/operator_overload_11.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"]
11 pub trait BitAnd<Rhs = Self> {
12 type Output;
13
14 fn bitand(self, rhs: Rhs) -> Self::Output;
15 }
16
17 impl BitAnd for i32 {
18 type Output = i32;
19
20 fn bitand(self, other: i32) -> i32 {
21 let res = self & other;
22
23 unsafe {
24 let a = "%i\n\0";
25 let b = a as *const str;
26 let c = b as *const i8;
27
28 printf(c, res);
29 }
30
31 res
32 }
33 }
34
35 fn main() -> i32 {
36 let a;
37 a = 1 & 1;
38
39 0
40 }