# Optimize generic functions for MIR by the compiler

**URL:** <https://internals.rust-lang.org/t/optimize-generic-functions-for-mir-by-the-compiler/23035>\
**Category:** internals\
**Created:** [June 3, 2025, 11:59am UTC](https://internals.rust-lang.org/t/optimize-generic-functions-for-mir-by-the-compiler/23035 "2025-06-03T11:59:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbstractiveNord](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/abstractivenord/32/12271_2.png) [@AbstractiveNord](https://internals.rust-lang.org/u/AbstractiveNord)\
**Post date:** [June 3, 2025, 11:59am UTC](https://internals.rust-lang.org/t/optimize-generic-functions-for-mir-by-the-compiler/23035/1 "2025-06-03T11:59:00Z")

</div>

I am not quite sure is it possible for now, but does Rust compiler have all necessary diagnostic to automatically convert generic functions into pairs of generic entry and inner function that do some work?

---

<div class="post-metadata">

**Author:** ![ekuber](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ekuber/32/1646_2.png) [@ekuber](https://internals.rust-lang.org/u/ekuber)\
**Post date:** [June 3, 2025, 12:30pm UTC](https://internals.rust-lang.org/t/optimize-generic-functions-for-mir-by-the-compiler/23035/2 "2025-06-03T12:30:57Z")

</div>

That was called "polymorphization" internally. There was an implementation that had issues and was removed some time back. There was a [recent thread about this](https://internals.rust-lang.org/t/add-back-polymorphization/22879).
