News for hackers. Stuff that matters.
Re:Oxide: A Formal Semantics for Rust by bluejekyll on Tuesday March 05, 2019 @07:24PM (#19315468)
One of the examples in the paper has some code that you can't actually write in Rust, it's close to this:

    let msg: &'msg str = "Hello World";
You can write something similar and allow the compiler to infer the lifetime:

    let msg: &'_ str = "Hello World";
I often find myself declaring the type when I get into confusing type issues in Rust, but you can't do that as easily with lifetimes. With non-lexical lifetimes this has been less of an issue, but still there are times when I would like to be able to declare the lifetime like the first example.

This error example shows the valid uses of lifetimes: https://doc.rust-lang.org/nightly/error-index.html#E0261

Re:Oxide: A Formal Semantics for Rust by webkike on Tuesday March 05, 2019 @09:01PM (#19315878)
I believe you can actually name the lifetime of a block, via the same mechanism that makes labeled breaks and continues possible.
Re:Oxide: A Formal Semantics for Rust by Retra on Wednesday March 06, 2019 @09:18AM (#19319045)
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: {}
Re:Oxide: A Formal Semantics for Rust by gpm on Tuesday March 05, 2019 @11:24PM (#19316391)
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.