Should &'a Value as &'a Trait
work?
#10766
Labels
A-lifetimes
Area: Lifetimes / regions
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Inspired by rust-dev posting:
https://mail.mozilla.org/pipermail/rust-dev/2013-November/007054.html
Here is the relevant bit of code from the post:
We need to ensure that for an expression are not obscured (#5723) by the cast.
<source> as <target>
that any borrowed pointers in the type ofA �collection of conditions sufficient to enforce this are listed in a comment in librustc/middle/kind.rs that I think is apropos here:
https://github.com/mozilla/rust/blob/master/src/librustc/middle/kind.rs#L488
However, there are probably other conditions that would also suffice that we might add to that set.
In particular, I do not see anything immediately wrong with the example from that mailing list post; the type-expression
&'a V
should ensure thatV
does not contain any lifetimes that are shorter than 'a, and therefore it should be safe, when<V: T>
to castv: &'a V
to a&'a T
.(It could be that I have misinterpreted the constraints imposed by `&'a V.)
cc: @nikomatsakis
The text was updated successfully, but these errors were encountered: