How smart is the compiler about avoiding monomorphization?

This has been asked before here, but that's four years old, so I'll check again to see if anything has changed.

Say I have a function that looks like this:

fn foo(id: impl Into<SimpleId>) {
    let id = id.into(); 
    // everything else uses id: SimpleId

It seems like it would be better to save space on instructions and do something like:

fn foo(id: impl Into<SimpleId>) {
    foo_inner(id.into());
}
fn foo_inner(id: SimpleId) { ... }

Now foo could also be inlined.

Is the Rust compiler smart enough to do that for me, in release/optimization mode? Or does it pay to do this manually?

If SimpleId were SomeBigThing, then the size of the moved object could come into play. But in my case both the SimpleId and the type that implements Into<SimpleId> are 8 bytes.

No, the compiler has not started optimizing this case. It does not even recognize when a function doesn’t depend on its generic parameters at all (such as if there was no .into() call): that is polymorphization, which was removed in 2024 due to being problematic.