Description
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:
trait T {}
fn f<'a, V: T>(v: &'a V) -> &'a T {
v as &'a T
}
We need to ensure that for an expression <source> as <target>
that any borrowed pointers in the type of
A �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 that V
does not contain any lifetimes that are shorter than 'a, and therefore it should be safe, when <V: T>
to cast v: &'a V
to a &'a T
.
(It could be that I have misinterpreted the constraints imposed by `&'a V.)
cc: @nikomatsakis