Skip to content

Missing symbol in generated dylib #117137

Description

@istankovic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions