]> git.proxmox.com Git - rustc.git/blob - src/test/codegen-units/partitioning/methods-are-with-self-type.rs
Update unsuspicious file list
[rustc.git] / src / test / codegen-units / partitioning / methods-are-with-self-type.rs
1 // Currently, all generic functions are instantiated in each codegen unit that
2 // uses them, even those not marked with #[inline], so this test does not make
3 // much sense at the moment.
4 // ignore-test
5
6 //
7 // We specify incremental here because we want to test the partitioning for
8 // incremental compilation
9 // incremental
10 // compile-flags:-Zprint-mono-items=lazy
11
12 #![allow(dead_code)]
13 #![feature(start)]
14
15 struct SomeType;
16
17 struct SomeGenericType<T1, T2>(T1, T2);
18
19 mod mod1 {
20 use super::{SomeType, SomeGenericType};
21
22 // Even though the impl is in `mod1`, the methods should end up in the
23 // parent module, since that is where their self-type is.
24 impl SomeType {
25 //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[0]::method[0] @@ methods_are_with_self_type[External]
26 fn method(&self) {}
27
28 //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[0]::associated_fn[0] @@ methods_are_with_self_type[External]
29 fn associated_fn() {}
30 }
31
32 impl<T1, T2> SomeGenericType<T1, T2> {
33 pub fn method(&self) {}
34 pub fn associated_fn(_: T1, _: T2) {}
35 }
36 }
37
38 trait Trait {
39 fn foo(&self);
40 fn default(&self) {}
41 }
42
43 // We provide an implementation of `Trait` for all types. The corresponding
44 // monomorphizations should end up in whichever module the concrete `T` is.
45 impl<T> Trait for T
46 {
47 fn foo(&self) {}
48 }
49
50 mod type1 {
51 pub struct Struct;
52 }
53
54 mod type2 {
55 pub struct Struct;
56 }
57
58 //~ MONO_ITEM fn methods_are_with_self_type::start[0]
59 #[start]
60 fn start(_: isize, _: *const *const u8) -> isize {
61 //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[1]::method[0]<u32, u64> @@ methods_are_with_self_type.volatile[WeakODR]
62 SomeGenericType(0u32, 0u64).method();
63 //~ MONO_ITEM fn methods_are_with_self_type::mod1[0]::{{impl}}[1]::associated_fn[0]<char, &str> @@ methods_are_with_self_type.volatile[WeakODR]
64 SomeGenericType::associated_fn('c', "&str");
65
66 //~ MONO_ITEM fn methods_are_with_self_type::{{impl}}[0]::foo[0]<methods_are_with_self_type::type1[0]::Struct[0]> @@ methods_are_with_self_type-type1.volatile[WeakODR]
67 type1::Struct.foo();
68 //~ MONO_ITEM fn methods_are_with_self_type::{{impl}}[0]::foo[0]<methods_are_with_self_type::type2[0]::Struct[0]> @@ methods_are_with_self_type-type2.volatile[WeakODR]
69 type2::Struct.foo();
70
71 //~ MONO_ITEM fn methods_are_with_self_type::Trait[0]::default[0]<methods_are_with_self_type::type1[0]::Struct[0]> @@ methods_are_with_self_type-type1.volatile[WeakODR]
72 type1::Struct.default();
73 //~ MONO_ITEM fn methods_are_with_self_type::Trait[0]::default[0]<methods_are_with_self_type::type2[0]::Struct[0]> @@ methods_are_with_self_type-type2.volatile[WeakODR]
74 type2::Struct.default();
75
76 0
77 }
78
79 //~ MONO_ITEM drop-glue i8