On Thu, Dec 3, 2026 at 12:14 PM Philipp Stanner <[email protected]> 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?

Generally, the justification for adding #[inline] to Rust functions is
because the Rust function does pretty much nothing else other than
call a C function, so you might as well call the C function directly,
if there's no additional meaningful logic in the Rust wrapper. If the
Rust function does have real logic, it's a different story.

Alice

Reply via email to