What exactly is promotion in rustc? is it like lambda lifting in functional compilers? just lifting closures / constants to the top level? Also, where can I find the rules governing what can and cannot be promoted?
const promotion allows for things like
let x: &'static str = &(3 + 4); by promoting the result of
3 + 4 to a constant
(someone should write https://rustc-dev-guide.rust-lang.org/mir/index.html?highlight=promotion#promoted-constants)
but yes, the rustc internals should be documented
I never think to check the reference.
I didn't understand the first sentence of the link @oli posted:
Promotion of a value expression to a 'static slot occurs when the expression could be written in a constant, borrowed, and dereferencing that borrow where the expression was originally written, without changing the runtime behavior.
Could use a re-wording?