]> git.proxmox.com Git - rustc.git/blame - src/test/codegen-units/generic-impl.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / codegen-units / generic-impl.rs
CommitLineData
7453a54e
SL
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
16struct Struct<T> {
17 x: T,
18 f: fn(x: T) -> T,
19}
20
21fn id<T>(x: T) -> T { x }
22
23impl<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
37pub struct LifeTimeOnly<'a> {
38 _a: &'a u32
39}
40
41impl<'a> LifeTimeOnly<'a> {
42
54a0048b 43 //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::foo[0]
7453a54e 44 pub fn foo(&self) {}
54a0048b 45 //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::bar[0]
7453a54e 46 pub fn bar(&'a self) {}
54a0048b 47 //~ TRANS_ITEM fn generic_impl::{{impl}}[1]::baz[0]
7453a54e
SL
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]
55fn main() {
54a0048b 56 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<i32>
7453a54e 57 //~ TRANS_ITEM fn generic_impl::id[0]<i32>
54a0048b 58 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<i32, i16>
7453a54e
SL
59 let _ = Struct::new(0i32).get(0i16);
60
54a0048b 61 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<i64>
7453a54e 62 //~ TRANS_ITEM fn generic_impl::id[0]<i64>
54a0048b 63 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<i64, i16>
7453a54e
SL
64 let _ = Struct::new(0i64).get(0i16);
65
54a0048b 66 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<char>
7453a54e 67 //~ TRANS_ITEM fn generic_impl::id[0]<char>
54a0048b 68 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<char, i16>
7453a54e
SL
69 let _ = Struct::new('c').get(0i16);
70
54a0048b 71 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<&str>
7453a54e 72 //~ TRANS_ITEM fn generic_impl::id[0]<&str>
54a0048b 73 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::get[0]<generic_impl::Struct[0]<&str>, i16>
7453a54e
SL
74 let _ = Struct::new(Struct::new("str")).get(0i16);
75
54a0048b 76 //~ TRANS_ITEM fn generic_impl::{{impl}}[0]::new[0]<generic_impl::Struct[0]<&str>>
7453a54e
SL
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