Debian Codegraph @

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

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