Skip to content

The impls of LifetimeFree on std are technically unsound (but likely fine in practice) #30

@Kixunil

Description

@Kixunil

Technically, it's possible for std to change any type to have an additional parameter with default being a type with lifetime parameter set to 'static. This is technically possible with any type, though doing it for arrays and such would require new syntax ([T; N]<X>?).

However, practically, this is very unlikely to happen. Still I'm calling it out in case you want to do something about it. I think that collections are closest to this happening because of the default allocator. If the global allocator ever becomes Whatever<'static> this crate will become unsound. Primitive types are probably the least likely.

Maybe it'd be best to try getting this into core. I've seen some discussion about allowing more casts, so maybe it'd be appealing especially if coupled with a derive macro that can check the type signature and implement the trait. (Should be really simple: if a type contains lifetime parameters emit an error pointing at them, if it doesn't take all type parameters T1...Tn and emit unsafe impl<T1: LifetimFree, T2: LifetimFree, T3: LifetimFree, ..., Tn: LifetimFree> LifetimFree for Foo {}).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions