Debian Codegraph @

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

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