On 12/3/26 12:14 PM, Philipp Stanner wrote:
> On Thu, 2026-12-03 at 11:41 +0100, Alice Ryhl wrote:
>> On Thu, Dec 3, 2026 at 11:26 AM Philipp Stanner <[email protected]> wrote:
>>> In C we spent years explaining to people that the compiler should
>>> decide what to inline, with only some exceptions. Yet for Rust we shall
>>> decide ourselves. Why?
>>
>> We make exactly the same decisions in C when we decide whether to
>> declare a function as 'static inline' in a header file, or as a normal
>> function.
> 
> Then why can't I decide that foo(), despite only consisting of three
> lines, is a slow path, unimportant, can have its own symbol and does
> not have to be inlined?

I guess the straightforward answer in this case is "because the maintainer
told you so". :)

This aside, you absolutely can if you have good reasons you don't want
something to be inlined. You can even add #[inline(never)] to force it not
being inlined.

Sashiko is just giving you a hint that you probably want to give the compiler
a hint, as it makes sense in this case.

That said, I'd love to get this hint already before the patch reaches Sashiko,
and I think Gary does consider adding it to Klint.

Reply via email to