]> git.lizzy.rs Git - rust.git/blob - src/test/codegen-units/partitioning/auxiliary/shared_generics_aux.rs
Make drop-glue take advantage of -Zshare-generics.
[rust.git] / src / test / codegen-units / partitioning / auxiliary / shared_generics_aux.rs
1 // NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
2 //       prevent drop-glue from participating in share-generics.
3 // compile-flags:-Zshare-generics=yes -Copt-level=0
4 // no-prefer-dynamic
5
6 #![crate_type="rlib"]
7
8 pub fn generic_fn<T>(x: T, y: T) -> (T, T) {
9     (x, y)
10 }
11
12 pub fn use_generic_fn_f32() -> (f32, f32) {
13     // This line causes drop glue for Foo to be instantiated. We want to make
14     // sure that this crate exports an instance to be re-used by share-generics.
15     let _ = Foo(0);
16
17     generic_fn(0.0f32, 1.0f32)
18 }
19
20 pub struct Foo(pub u32);
21
22 impl Drop for Foo {
23     fn drop(&mut self) {
24         println!("foo");
25     }
26 }