We currently don't correctly handle non-'static lifetimes in const generics. Until #74051 is merged we ICE when a non-'static lifetime is hit, as seen in #60814.
Many uses for const generics does not hit this limitation, but the following case has been brought up:
fn test<'a, const VALUE: std::mem::Discriminant<Enum<'a>>(v: Enum<'a>) -> bool {
std::mem::discriminant(&v) == VALUE
}
as quoted from @lcnr on Zulip
mem::Discriminant is invariant so VALUE has to be mem::Discriminant of Enum<'a> and can't use Enum<'static>.
@varkor @eddyb @nikomatsakis
We currently don't correctly handle non-
'staticlifetimes in const generics. Until #74051 is merged we ICE when a non-'staticlifetime is hit, as seen in #60814.Many uses for const generics does not hit this limitation, but the following case has been brought up:
as quoted from @lcnr on Zulip
@varkor @eddyb @nikomatsakis