I have a question related to Rust issue # 34284 . I understand why this is not possible in the current rust, but I'm curious what change (break) is needed to avoid highlighting in Cow::clone .
I suspect that this will require some kind of specialization for life. Something like (pseudo-rust):
impl<'a, B: ?Sized> Clone for Cow<'a, B> where B: ToOwned { fn clone(&'b self) -> Cow<'a, B> { if { return } else { return } } }
RFC 1210 states that life-cycle specialization is not possible:
We cannot, because when the compiler is sent to the actual code ("trans"), life information has been erased
but later he says that
Unfortunately, we cannot easily rule out unwanted time-dependent specializations, because they can be "hidden" behind innocent looks.
Does this mean that:
- Optimization of
Cow::clone impossible without changing the compiler, so that information about the lifetime is stored longer - could only be optimized for language-defined lifetimes (
'static ) if RFC 1210 allowed this?
source share