Always-inline closure passed via impl FnOnce
doesn't inline
#96929
Labels
A-closures
Area: Closures (`|…| { … }`)
A-codegen
Area: Code generation
C-bug
Category: This is a bug.
An example (try it in debug configuration)
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=17e7dce927938012e15cd503caeb0cce
I expected to see this happen:
call_once
markedalwaysinline
Instead, this happened:
call_once
markedinlinehint
The closure itself is inlined, however the
call_once
is not, and when usingimpl FnOnce
, effectively defeats the purpose of the#[inline(always)]
.Fn
andFnMut
don't appear to have this issue (or LLVM is more likely to inline them, at least).Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: