Stream: t-compiler/help

Topic: identity conversion is not inlined


Joonatan Saarhelo (Jul 22 2020 at 17:33, on Zulip):

I've spent the last two days looking at a case where adding an unnecessary .into() makes the compiler generate more assembly.

I tried putting #[inline(always)] on the two relevant trait impls and it made my code smaller but the case I was looking at earlier still didn't inline.

Today I tried to make a minimal reproduction of it but it is too flaky for that. I am currently at a point where adding a feature flag to Cargo.toml makes it work properly, even if the flag is not used. It also stopped reproducing on stable at some point in the minimization process but continued to work on nightly and my own stage2.

Is this a bug? I thought inline(always) was supposed to force inlining, which should result in no code being generated.

Jake Goulding (Jul 22 2020 at 17:35, on Zulip):

always === "try really hard". It doesn't actually mean always, sadly.

Joshua Nelson (Jul 22 2020 at 17:38, on Zulip):

Jake Goulding said:

always === "try really hard". It doesn't actually mean always, sadly.

https://github.com/rust-lang/rust/issues/53827

Joonatan Saarhelo (Jul 22 2020 at 17:42, on Zulip):

ok, that explains it somewhat

Joonatan Saarhelo (Jul 22 2020 at 17:43, on Zulip):

But maybe my changes should be merged? At least inlining the trivial case of From is always good. I'm less sure about the Into based on From

Jake Goulding (Jul 22 2020 at 17:44, on Zulip):

I don't see any particular reason not to, so it seems worth opening a PR and getting smarter people than me to look at it.

Joonatan Saarhelo (Jul 22 2020 at 17:45, on Zulip):

Ok, will do

Last update: Sep 28 2020 at 16:30UTC