Add inline attributes documentation.#11491
Conversation
There was a problem hiding this comment.
It would be good to mention that having either #[inline] or #[inline(always)] causes the function to be serialised to crate metadata, and so allow cross-crate inlining.
There was a problem hiding this comment.
It's also worth mentioning that #[inline(always)] may not always work due to indirection through function pointers. Link-time optimization allows cross-crate inlining without manual annotation so that's worth noting too.
|
Updated with @huonw's comments. |
doc/rust.md
Outdated
There was a problem hiding this comment.
It's not just function call overhead: inlining allows secondary optimisations like constant folding and dead-code elimination.
I think it would also be worth mentioning that the compiler will actually do this automatically (estimating whether it will be beneficial using heuristics like the size of the function, and the number of times it is called).
There was a problem hiding this comment.
I've added more details about compiler automatically inlining functions.
However I think going into secondary optimizations from inlining functions is going too much into detail...
There was a problem hiding this comment.
Inlining isn't usually about removing the overhead of a function call, so I think that's better left unsaid if you're not going to go into more detail.
|
Removed info about inlining advantages / disadvantages. |
…es, r=alexcrichton Closes #7959.
Closes #7959.