]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/item-collection/trait-implementations.rs
Imported Upstream version 1.10.0+dfsg1
[rustc.git] / src / test / codegen-units / item-collection / trait-implementations.rs
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-tidy-linelength
12 // compile-flags:-Zprint-trans-items=eager
13
14 #![deny(dead_code)]
15
16 pub trait SomeTrait {
17 fn foo(&self);
18 fn bar<T>(&self, x: T);
19 }
20
21 impl SomeTrait for i64 {
22
23 //~ TRANS_ITEM fn trait_implementations::{{impl}}[0]::foo[0]
24 fn foo(&self) {}
25
26 fn bar<T>(&self, _: T) {}
27 }
28
29 impl SomeTrait for i32 {
30
31 //~ TRANS_ITEM fn trait_implementations::{{impl}}[1]::foo[0]
32 fn foo(&self) {}
33
34 fn bar<T>(&self, _: T) {}
35 }
36
37 pub trait SomeGenericTrait<T> {
38 fn foo(&self, x: T);
39 fn bar<T2>(&self, x: T, y: T2);
40 }
41
42 // Concrete impl of generic trait
43 impl SomeGenericTrait<u32> for f64 {
44
45 //~ TRANS_ITEM fn trait_implementations::{{impl}}[2]::foo[0]
46 fn foo(&self, _: u32) {}
47
48 fn bar<T2>(&self, _: u32, _: T2) {}
49 }
50
51 // Generic impl of generic trait
52 impl<T> SomeGenericTrait<T> for f32 {
53
54 fn foo(&self, _: T) {}
55 fn bar<T2>(&self, _: T, _: T2) {}
56 }
57
58 //~ TRANS_ITEM fn trait_implementations::main[0]
59 fn main() {
60 //~ TRANS_ITEM fn trait_implementations::{{impl}}[1]::bar[0]<char>
61 0i32.bar('x');
62
63 //~ TRANS_ITEM fn trait_implementations::{{impl}}[2]::bar[0]<&str>
64 0f64.bar(0u32, "&str");
65
66 //~ TRANS_ITEM fn trait_implementations::{{impl}}[2]::bar[0]<()>
67 0f64.bar(0u32, ());
68
69 //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::foo[0]<char>
70 0f32.foo('x');
71
72 //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::foo[0]<i64>
73 0f32.foo(-1i64);
74
75 //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::bar[0]<u32, ()>
76 0f32.bar(0u32, ());
77
78 //~ TRANS_ITEM fn trait_implementations::{{impl}}[3]::bar[0]<&str, &str>
79 0f32.bar("&str", "&str");
80 }
81
82 //~ TRANS_ITEM drop-glue i8