]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/generic-impl.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / codegen-units / generic-impl.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 struct Struct<T> {
17 x: T,
18 f: fn(x: T) -> T,
19 }
20
21 fn id<T>(x: T) -> T { x }
22
23 impl<T> Struct<T> {
24
25 fn new(x: T) -> Struct<T> {
26 Struct {
27 x: x,
28 f: id
29 }
30 }
31
32 fn get<T2>(self, x: T2) -> (T, T2) {
33 (self.x, x)
34 }
35 }
36
37 pub struct LifeTimeOnly<'a> {
38 _a: &'a u32
39 }
40
41 impl<'a> LifeTimeOnly<'a> {
42
43 //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::foo[0]
44 pub fn foo(&self) {}
45 //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::bar[0]
46 pub fn bar(&'a self) {}
47 //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::baz[0]
48 pub fn baz<'b>(&'b self) {}
49
50 pub fn non_instantiated<T>(&self) {}
51 }
52
53
54 //~ TRANS_ITEM fn generic_impl::main[0]
55 fn main() {
56 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<i32>
57 //~ TRANS_ITEM fn generic_impl::id[0]<i32>
58 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<i32, i16>
59 let _ = Struct::new(0i32).get(0i16);
60
61 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<i64>
62 //~ TRANS_ITEM fn generic_impl::id[0]<i64>
63 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<i64, i16>
64 let _ = Struct::new(0i64).get(0i16);
65
66 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<char>
67 //~ TRANS_ITEM fn generic_impl::id[0]<char>
68 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<char, i16>
69 let _ = Struct::new('c').get(0i16);
70
71 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<&str>
72 //~ TRANS_ITEM fn generic_impl::id[0]<&str>
73 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<generic_impl::Struct[0]<&str>, i16>
74 let _ = Struct::new(Struct::new("str")).get(0i16);
75
76 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<generic_impl::Struct[0]<&str>>
77 //~ TRANS_ITEM fn generic_impl::id[0]<generic_impl::Struct[0]<&str>>
78 let _ = (Struct::new(Struct::new("str")).f)(Struct::new("str"));
79 }
80
81 //~ TRANS_ITEM drop-glue i8