reference icon indicating copy to clipboard operation
reference copied to clipboard

Clarify warning regarding changes of rules for temporary lifetime extension

Open JanBeh opened this issue 3 years ago • 2 comments

The subsection on temporary lifetime extension currently contains the following warning:

Note: The exact rules for temporary lifetime extension are subject to change. This is describing the current behavior only.

It is not clear under which conditions these rules may change. A new compiler version? A new edition? Without clarification, this might be understood as a discouragement to rely on temporary lifetime extension in productive code. Is that intended?

JanBeh avatar Nov 10 '21 17:11 JanBeh

Link to the respective subsection: https://doc.rust-lang.org/reference/destructors.html#temporary-lifetime-extension

JanBeh avatar Nov 10 '21 17:11 JanBeh

One thing I'd like to add, it should potentially keep a discouraging message at least for certain contexts. For example, I would assume that it's a bad idea to rely on the current behavior of lifetime extensions to keep unsafe sections sound. Maybe something along "You need to ensure values your unsafe code relies on have a proper non-temporary location".

phaylon avatar Nov 10 '21 17:11 phaylon