Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

With LTO, yes. I always forget if #[inline] does or not.


#[inline] is all about cross-crate work; inside a crate, items not marked #[inline] may still be inlined by the optimiser, but it doesn’t do cross-crate inlining without #[inline] or LTO.


Not all about. It gives an inline hint to LLVM, making it inlined more eagerly (even within a single crate) than the default.


Are generics not inlined when appropriate even without #[inline] or LTO?


You don't need the #[inline] attribute when generics are involved, because Rust already has to cross-crate-export function metadata when generics are involved because otherwise it would be impossible to monomorphize. At that point, LLVM will inline the monomorphized functions as it deems fit.


Yes, #[inline] works across crates




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: