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