Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upThere is no way to `unsafe impl` `'static` #31196
Comments
This comment has been minimized.
This comment has been minimized.
|
I am not sure if this is at all feasible, if it's completely bonkers feel free to close. |
This comment has been minimized.
This comment has been minimized.
|
This feels somewhat crazy, but it'd be oh-so-useful: I've had to box things behind trait objects just so that I can erase the lifetime (transmuting |
huonw
added
I-nominated
T-lang
labels
Jan 26, 2016
This comment has been minimized.
This comment has been minimized.
|
If we had 'anonymous/injected type parameter which doesn't unify with anything but itself' as a native part of the type system, it would also solve this problem (using lifetimes for this is admittedly a hack). |
This comment has been minimized.
This comment has been minimized.
|
That solves using lifetimes as a tag, but not having to (ab)use trait objects to force things to be |
This comment has been minimized.
This comment has been minimized.
|
This is currently dangerous because rustc assumes that every lifetime that is |
aturon
removed
the
I-nominated
label
Jan 30, 2016
This comment has been minimized.
This comment has been minimized.
|
The lang team discussed this issue, and felt that while there are plausible motivations for the feature, there are also significant dangers. We would consider a fleshed out RFC in this area presenting a strong argument for the importance of the feature and mitigation of the pitfalls that have been raised here. |
reem commentedJan 26, 2016
This would be extremely useful when using invariant lifetimes as a marker for e.g. safe unchecked indexing, it would be nice to be able to say
unsafe impl<'id> 'static for InvariantLifetime<'id> {}(whereInvariantLifetime<'a>isPhantomData<fn(&'a ()) -> &'a ()>).