I believe you can actually name the lifetime of a block, via the same mechanism that makes labeled breaks and continues possible.
I think that was just a proposal that never got accepted? Never see it in real code either way.
Re:Oxide: A Formal Semantics for Rust
by bluejekyll on Tuesday March 05, 2019 @09:08PM
(#19315901)
Do you have an example of what you mean?
Re:Oxide: A Formal Semantics for Rust
by coolreader18 on Tuesday March 05, 2019 @10:45PM
(#19316257)
Like this:
'a: {
let a_var: u32 = 42;
let a_ref: &'a u32 = &a_var;
} // ^^^^^ only valid in 'a: {}That doesn't compile with "use of undeclared lifetime name `'a`"
Re:Oxide: A Formal Semantics for Rust
by steveklabnik on Wednesday March 06, 2019 @03:55AM
(#19317387)
You can name loop labels like this, but you cannot use them to introduce actual lifetimes, that’s right.
This error example shows the valid uses of lifetimes: https://doc.rust-lang.org/nightly/error-index.html#E0261