There's a weird Rust compiler feature that I've wanted for several years: inlining control overlays.

Basically: I maintain firmware with a pinned toolchain version, and sometimes that toolchain makes mistakes in deciding what should be inlined. Sometimes those mistakes have very extreme consequences (e.g. deciding not to inline certain slice or range iterator functions basically disables bounds check elimination!). "Fixing" this by poking randomly at unrelated optimizations until I get the result I want is very error prone and not future proof.

I would like to submit a file to the compiler that applies inline-always/never pragmas _to functions I do not control,_ such as in third-party crates and Core.

Yes, this file would probably need to be adjusted at each toolchain upgrade, but it seems like an acceptable compromise. We will never get an algorithm that is correct for all cases (this is one of those Hard Problems) so having an escape hatch is important.

I've found some sympathetic ears at RustWeek, which is very exciting!

0

If you have a fediverse account, you can quote this note from your own instance. Search https://hachyderm.io/users/cliffle/statuses/114515980271564408 on your instance and quote it. (Note that quoting is not supported in Mastodon.)