]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/cross-crate-trait-method.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / codegen-units / cross-crate-trait-method.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 // aux-build:cgu_export_trait_method.rs
17 extern crate cgu_export_trait_method;
18
19 use cgu_export_trait_method::Trait;
20
21 //~ TRANS_ITEM fn cross_crate_trait_method::main[0]
22 fn main()
23 {
24 // The object code of these methods is contained in the external crate, so
25 // calling them should *not* introduce codegen items in the current crate.
26 let _: (u32, u32) = Trait::without_default_impl(0);
27 let _: (char, u32) = Trait::without_default_impl(0);
28
29 // Currently, no object code is generated for trait methods with default
30 // implemenations, unless they are actually called from somewhere. Therefore
31 // we cannot import the implementations and have to create our own inline.
32 //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl[0]<u32>
33 let _ = Trait::with_default_impl(0u32);
34 //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl[0]<char>
35 let _ = Trait::with_default_impl('c');
36
37
38
39 //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<u32, &str>
40 let _ = Trait::with_default_impl_generic(0u32, "abc");
41 //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<u32, bool>
42 let _ = Trait::with_default_impl_generic(0u32, false);
43
44 //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<char, i16>
45 let _ = Trait::with_default_impl_generic('x', 1i16);
46 //~ TRANS_ITEM fn cgu_export_trait_method::Trait[0]::with_default_impl_generic[0]<char, i32>
47 let _ = Trait::with_default_impl_generic('y', 0i32);
48
49 //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[1]::without_default_impl_generic[0]<char>
50 let _: (u32, char) = Trait::without_default_impl_generic('c');
51 //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[1]::without_default_impl_generic[0]<bool>
52 let _: (u32, bool) = Trait::without_default_impl_generic(false);
53
54 //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[0]::without_default_impl_generic[0]<char>
55 let _: (char, char) = Trait::without_default_impl_generic('c');
56 //~ TRANS_ITEM fn cgu_export_trait_method::{{impl}}[0]::without_default_impl_generic[0]<bool>
57 let _: (char, bool) = Trait::without_default_impl_generic(false);
58 }
59
60 //~ TRANS_ITEM drop-glue i8