]> git.proxmox.com Git - rustc.git/blame - src/test/codegen-units/item-collection/trait-implementations.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / codegen-units / item-collection / trait-implementations.rs
CommitLineData
94b46f34 1// compile-flags:-Zprint-mono-items=eager
7453a54e
SL
2
3#![deny(dead_code)]
ff7c6d11 4#![feature(start)]
7453a54e
SL
5
6pub trait SomeTrait {
7 fn foo(&self);
8 fn bar<T>(&self, x: T);
9}
10
11impl SomeTrait for i64 {
12
1b1a35ee 13 //~ MONO_ITEM fn <i64 as SomeTrait>::foo
7453a54e
SL
14 fn foo(&self) {}
15
16 fn bar<T>(&self, _: T) {}
17}
18
19impl SomeTrait for i32 {
20
1b1a35ee 21 //~ MONO_ITEM fn <i32 as SomeTrait>::foo
7453a54e
SL
22 fn foo(&self) {}
23
24 fn bar<T>(&self, _: T) {}
25}
26
27pub trait SomeGenericTrait<T> {
28 fn foo(&self, x: T);
29 fn bar<T2>(&self, x: T, y: T2);
30}
31
32// Concrete impl of generic trait
33impl SomeGenericTrait<u32> for f64 {
34
1b1a35ee 35 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::foo
7453a54e
SL
36 fn foo(&self, _: u32) {}
37
38 fn bar<T2>(&self, _: u32, _: T2) {}
39}
40
41// Generic impl of generic trait
42impl<T> SomeGenericTrait<T> for f32 {
43
44 fn foo(&self, _: T) {}
45 fn bar<T2>(&self, _: T, _: T2) {}
46}
47
1b1a35ee 48//~ MONO_ITEM fn start
ff7c6d11
XL
49#[start]
50fn start(_: isize, _: *const *const u8) -> isize {
1b1a35ee 51 //~ MONO_ITEM fn <i32 as SomeTrait>::bar::<char>
7453a54e
SL
52 0i32.bar('x');
53
1b1a35ee 54 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<&str>
7453a54e
SL
55 0f64.bar(0u32, "&str");
56
1b1a35ee 57 //~ MONO_ITEM fn <f64 as SomeGenericTrait<u32>>::bar::<()>
7453a54e
SL
58 0f64.bar(0u32, ());
59
1b1a35ee 60 //~ MONO_ITEM fn <f32 as SomeGenericTrait<char>>::foo
7453a54e
SL
61 0f32.foo('x');
62
1b1a35ee 63 //~ MONO_ITEM fn <f32 as SomeGenericTrait<i64>>::foo
7453a54e
SL
64 0f32.foo(-1i64);
65
1b1a35ee 66 //~ MONO_ITEM fn <f32 as SomeGenericTrait<u32>>::bar::<()>
7453a54e
SL
67 0f32.bar(0u32, ());
68
1b1a35ee 69 //~ MONO_ITEM fn <f32 as SomeGenericTrait<&str>>::bar::<&str>
7453a54e 70 0f32.bar("&str", "&str");
ff7c6d11
XL
71
72 0
7453a54e 73}