I tried compiling this code with rustc 1.75.0-nightly (249624b 2023-10-20):
pub fn foo1(x: Option<bool>) -> bool {
x.is_some()
}
pub fn foo2(x: Option<bool>) -> bool {
x.unwrap()
}
using rustc a.rs -O --crate-type dylib and expected that both foo1 and foo2 are present in the generated dylib.
However, only foo2 is:
$ nm --defined-only -C liba.so | grep foo
00000000000532b0 T a::foo2
MIR contains foo1:
fn foo1(_1: Option<bool>) -> bool {
debug x => _1;
let mut _0: bool;
let mut _2: &std::option::Option<bool>;
scope 1 (inlined Option::<bool>::is_some) {
debug self => _2;
let mut _3: isize;
}
bb0: {
StorageLive(_2);
_2 = &_1;
StorageLive(_3);
_3 = discriminant(_1);
_0 = Eq(_3, const 1_isize);
StorageDead(_3);
StorageDead(_2);
return;
}
}
however, it's missing from LLVM IR.
I tried compiling this code with rustc 1.75.0-nightly (249624b 2023-10-20):
using
rustc a.rs -O --crate-type dyliband expected that bothfoo1andfoo2are present in the generated dylib.However, only
foo2is:$ nm --defined-only -C liba.so | grep foo 00000000000532b0 T a::foo2MIR contains
foo1:however, it's missing from LLVM IR.