Debian Codegraph @

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

raw
1 /* { dg-output "Hello World 123\r*\n" }*/
2 extern "C" {
3 fn printf(s: *const i8, ...);
4 }
5
6 #[lang = "sized"]
7 pub trait Sized {}
8
9 struct Foo<T>(T);
10
11 struct Bar<T> {
12 a: Foo<T>,
13 b: bool,
14 // { dg-warning "field is never read" "" { target *-*-* } .-1 }
15 }
16
17 fn test<T>(a: Bar<T>) -> Foo<T> {
18 a.a
19 }
20
21 fn main() -> i32 {
22 let a: Bar<i32> = Bar::<i32> {
23 a: Foo::<i32>(123),
24 b: true,
25 };
26 let result: Foo<i32> = test(a);
27
28 unsafe {
29 let a = "Hello World %i\n";
30 let b = a as *const str;
31 let c = b as *const i8;
32
33 printf(c, result.0);
34 }
35 0
36 }