Async Rust generates bloated state machines with unoptimized Returned/Panicked states, trivial futures, and duplicate suspend states; a compiler Project Goal aims to fix this at the MIR level.
Key Takeaways
Replacing poll-after-completion panics with Poll::Pending in release builds yielded 2-5% binary size reduction in async embedded firmware.
Trivial futures like async { 5 } still generate a full 3-state machine; eliminating the state machine entirely saved ~0.2% binary size.
LLVM cannot reliably optimize away async bloat because panic branches block constant folding; godbolt confirms bar does not reduce to Poll::Ready(10) even when foo is trivial.
Duplicate suspend states from match-arm await points can be collapsed by refactoring code to hoist the discriminant before a single await, cutting MIR from 456 lines toward a single state.
Future inlining at the MIR level (before LLVM) could collapse nested state machines for the common async trait adapter pattern, but rustc discards per-future metadata after transformation.
Hacker News Comment Review
No substantive HN discussion yet; one commenter praised the deep-dive but flagged the title as overly dramatic relative to the optimization-focused content.