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