Debian Codegraph @

gcc/testsuite/rust/execute/torture/issue-851.rs

raw
1 /* { dg-output "Result: 123\r*\n" } */
2 extern "C" {
3 fn printf(s: *const i8, ...);
4 }
5
6 #[lang = "sized"]
7 pub trait Sized {}
8
9 enum Foo<T> {
10 A,
11 B(T),
12 }
13
14 fn inspect(a: Foo<i32>) {
15 match a {
16 Foo::A => unsafe {
17 let a = "A\n\0";
18 let b = a as *const str;
19 let c = b as *const i8;
20
21 printf(c);
22 },
23 Foo::B(x) => unsafe {
24 let a = "Result: %i\n\0";
25 let b = a as *const str;
26 let c = b as *const i8;
27
28 printf(c, x);
29 },
30 }
31 }
32
33 fn main() -> i32 {
34 let a = Foo::B(123);
35 inspect(a);
36
37 0
38 }