// This test case makes sure that two identical invocations of the compiler // (i.e., same code base, same compile-flags, same compiler-versions, etc.) // produce the same output. In the past, symbol names of monomorphized functions // were not deterministic (which we want to avoid). // // The test tries to exercise as many different paths into symbol name // generation as possible: // // - regular functions // - generic functions // - methods // - statics // - closures // - enum variant constructors // - tuple struct constructors // - drop glue // - FnOnce adapters // - Trait object shims // - Fn Pointer shims // ignore-tidy-linelength #![allow(dead_code, warnings)] extern crate reproducible_build_aux; static STATIC: i32 = 1234; pub struct Struct { x: T1, y: T2, } fn regular_fn(_: i32) {} fn generic_fn() {} impl Drop for Struct { fn drop(&mut self) {} } pub enum Enum { Variant1, Variant2(u32), Variant3 { x: u32 }, } struct TupleStruct(i8, i16, i32, i64); impl TupleStruct { pub fn bar(&self) {} } trait Trait { fn foo(&self); } impl Trait for u64 { fn foo(&self) {} } impl reproducible_build_aux::Trait for TupleStruct { fn foo(&self) {} } fn main() { regular_fn(STATIC); generic_fn::(); generic_fn::>(); generic_fn::, reproducible_build_aux::Struct>(); let dropped = Struct { x: "", y: 'a' }; let _ = Enum::Variant1; let _ = Enum::Variant2(0); let _ = Enum::Variant3 { x: 0 }; let _ = TupleStruct(1, 2, 3, 4); let closure = |x| x + 1i32; fn inner i32>(f: F) -> i32 { f(STATIC) } println!("{}", inner(closure)); let object_shim: &Trait = &0u64; object_shim.foo(); fn with_fn_once_adapter(f: F) { f(0); } with_fn_once_adapter(|_: i32| {}); reproducible_build_aux::regular_fn(STATIC); reproducible_build_aux::generic_fn::(); reproducible_build_aux::generic_fn::>(); reproducible_build_aux::generic_fn::, reproducible_build_aux::Struct>( ); let _ = reproducible_build_aux::Enum::Variant1; let _ = reproducible_build_aux::Enum::Variant2(0); let _ = reproducible_build_aux::Enum::Variant3 { x: 0 }; let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4); let object_shim: &reproducible_build_aux::Trait = &TupleStruct(0, 1, 2, 3); object_shim.foo(); let pointer_shim: &Fn(i32) = ®ular_fn; TupleStruct(1, 2, 3, 4).bar(); }