1 // This test case makes sure that two identical invocations of the compiler
2 // (i.e., same code base, same compile-flags, same compiler-versions, etc.)
3 // produce the same output. In the past, symbol names of monomorphized functions
4 // were not deterministic (which we want to avoid).
6 // The test tries to exercise as many different paths into symbol name
7 // generation as possible:
10 // - generic functions
14 // - enum variant constructors
15 // - tuple struct constructors
18 // - Trait object shims
21 #![allow(dead_code, warnings)]
23 extern crate reproducible_build_aux;
25 static STATIC: i32 = 1234;
27 pub struct Struct<T1, T2> {
32 fn regular_fn(_: i32) {}
34 fn generic_fn<T1, T2>() {}
36 impl<T1, T2> Drop for Struct<T1, T2> {
46 struct TupleStruct(i8, i16, i32, i64);
56 impl Trait<i32, u64> for u64 {
60 impl reproducible_build_aux::Trait<char, String> for TupleStruct {
66 generic_fn::<u32, char>();
67 generic_fn::<char, Struct<u32, u64>>();
68 generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
70 let dropped = Struct {
75 let _ = Enum::Variant1;
76 let _ = Enum::Variant2(0);
77 let _ = Enum::Variant3 { x: 0 };
78 let _ = TupleStruct(1, 2, 3, 4);
84 fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
88 println!("{}", inner(closure));
90 let object_shim: &Trait<i32, u64> = &0u64;
93 fn with_fn_once_adapter<F: FnOnce(i32)>(f: F) {
97 with_fn_once_adapter(|_:i32| { });
99 reproducible_build_aux::regular_fn(STATIC);
100 reproducible_build_aux::generic_fn::<u32, char>();
101 reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
102 reproducible_build_aux::generic_fn::<Struct<u64, u32>,
103 reproducible_build_aux::Struct<u32, u64>>();
105 let _ = reproducible_build_aux::Enum::Variant1;
106 let _ = reproducible_build_aux::Enum::Variant2(0);
107 let _ = reproducible_build_aux::Enum::Variant3 { x: 0 };
108 let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4);
110 let object_shim: &reproducible_build_aux::Trait<char, String> = &TupleStruct(0, 1, 2, 3);
113 let pointer_shim: &Fn(i32) = ®ular_fn;
115 TupleStruct(1, 2, 3, 4).bar();