Consider this code:
#![inline(never)]
pub fn f(x: u64) -> u64 {
x + 1
}
pub fn g(x: u64) -> u64 {
f(x) + 1
}
and the resulting assembly:
playground::f:
leaq 1(%rdi), %rax
retq
playground::g:
leaq 2(%rdi), %rax
retq
I know I was hoping for a lot there, and I know that #[inline(never)] is just a suggestion. That said, given that I didn't get a warning here I would have expected removing the ! to produce the same output. But
#[inline(never)]
pub fn f(x: u64) -> u64 {
x + 1
}
pub fn g(x: u64) -> u64 {
f(x) + 1
}
yields
playground::f:
leaq 1(%rdi), %rax
retq
playground::g:
pushq %rax
callq *playground::f@GOTPCREL(%rip)
addq $1, %rax
popq %rcx
retq
If #![inline(never)] is supposed to work, it would be nice to have it work here. If it is not, it would be nice to get a warning lint.
(It would also be nice if inline(never) was a requirement, not just a suggestion. But that's a separate issue, I think.)
Meta
Built on the playground in release mode. Same behavior with rustc stable 1.41.0 and 1.43.0-nightly (2020-02-20 2c462a2f776b899d4674)
Consider this code:
and the resulting assembly:
I know I was hoping for a lot there, and I know that
#[inline(never)]is just a suggestion. That said, given that I didn't get a warning here I would have expected removing the!to produce the same output. Butyields
If
#![inline(never)]is supposed to work, it would be nice to have it work here. If it is not, it would be nice to get a warning lint.(It would also be nice if
inline(never)was a requirement, not just a suggestion. But that's a separate issue, I think.)Meta
Built on the playground in release mode. Same behavior with
rustcstable1.41.0and1.43.0-nightly (2020-02-20 2c462a2f776b899d4674)