External Publication
Visit Post

[Discussion] A perspective on super let: could a related “lift” capability ever belong in Rust’s macro system?

Rust Internals [Unofficial] April 26, 2026
Source

At this point there is a question: should we add &mut Context to proc macros or some kind of primitive, not exactly super let, that the macro will expand to, informing the compiler to do the following transformation:

place this value in an enclosing drop scope, while exposing only a hygienic local handle to it.

There, for example, the handle for proc macro may be the id of the placed "instruction". Both are technically equivalent because the latter can be viewed as a functional style rewrite of the former, with all conditional super let, as well as other subtleties, handled.

I believe that for RFC there should be previous discussion about other use cases that will benefit from the context being passed. Otherwise, an argument that super let is a new core part of the language and its syntax is not as strong, because it can be made into a compiler built-in macro, just like format_args!.

Please note that super let doesn't only come up in macros, it can also be used in situations like this:

let mut foo;
let mut bar;
let mut baz;

let qux: &mut dyn Iter = if quux {
    foo = foo_lock.borrow_mut();
    bar = foo.bar();
    &mut bar
} else {
    baz = baz.iter();
    &mut baz
}

Discussion in the ATmosphere

Loading comments...