Skip to content

Fix #[inline(always)] for recursive functions #599

Closed
@antoyo

Description

@antoyo

The following code:

#[inline(always)]
fn my_func(arg: i32) {
    if arg > 1 {
        my_func(arg - 1);
    }
}

fn main() {
    my_func(10);
}

triggers the following error:

libgccjit.so: error: : inlining failed in call to ‘always_inline’ ‘_ZN9test_rust7my_func17h0d9fc1667ee3d8a0E’: function not considered for inlining
libgccjit.so: src/main.rs:4:9: note: : called from here

As noted here, always_inline is not an optimization hint while #[inline(always)] is a hint as noted in the reference.

I'm not sure what the equivalent would be in GCC, though.

Maybe check what clang is doing (since it also has the issue) vs what rustc is doing.

#[rustc_force_inline] is possibly implemented via always_inline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions