]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/item-collection/trait-method-default-impl.rs
bfcdb6fa142bcde2869a386012f129bce586e9dd
[rustc.git] / src / test / codegen-units / item-collection / trait-method-default-impl.rs
1 // compile-flags:-Zprint-mono-items=eager -Zpolymorphize=on
2
3 #![deny(dead_code)]
4 #![feature(start)]
5
6 trait SomeTrait {
7 fn foo(&self) { }
8 fn bar<T>(&self, x: T) -> T { x }
9 }
10
11 impl SomeTrait for i8 {
12 // take the default implementations
13
14 // For the non-generic foo(), we should generate a codegen-item even if it
15 // is not called anywhere
16 //~ MONO_ITEM fn <i8 as SomeTrait>::foo
17 }
18
19 trait SomeGenericTrait<T1> {
20 fn foo(&self) { }
21 fn bar<T2>(&self, x: T1, y: T2) {}
22 }
23
24 // Non-generic impl of generic trait
25 impl SomeGenericTrait<u64> for i32 {
26 // take the default implementations
27
28 // For the non-generic foo(), we should generate a codegen-item even if it
29 // is not called anywhere
30 //~ MONO_ITEM fn <i32 as SomeGenericTrait<T1>>::foo
31 }
32
33 // Non-generic impl of generic trait
34 impl<T1> SomeGenericTrait<T1> for u32 {
35 // take the default implementations
36 // since nothing is monomorphic here, nothing should be generated unless used somewhere.
37 }
38
39 //~ MONO_ITEM fn start
40 #[start]
41 fn start(_: isize, _: *const *const u8) -> isize {
42 //~ MONO_ITEM fn <i8 as SomeTrait>::bar::<char>
43 let _ = 1i8.bar('c');
44
45 //~ MONO_ITEM fn <i8 as SomeTrait>::bar::<&str>
46 let _ = 2i8.bar("&str");
47
48 //~ MONO_ITEM fn <i32 as SomeGenericTrait<u64>>::bar::<char>
49 0i32.bar(0u64, 'c');
50
51 //~ MONO_ITEM fn <i32 as SomeGenericTrait<u64>>::bar::<&str>
52 0i32.bar(0u64, "&str");
53
54 //~ MONO_ITEM fn <u32 as SomeGenericTrait<i8>>::bar::<&[char; 1]>
55 0u32.bar(0i8, &['c']);
56
57 //~ MONO_ITEM fn <u32 as SomeGenericTrait<i16>>::bar::<()>
58 0u32.bar(0i16, ());
59
60 0
61 }