Open
Description
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
}
mem::Discriminant
is invariant soVALUE
has to bemem::Discriminant
ofEnum<'a>
and can't useEnum<'static>
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
nikomatsakis commentedon Jul 16, 2020
This is "just" an implementation limitation, correct?
lcnr commentedon Jul 16, 2020
Mostly, it should be theoretically fine, but ends up with similar problems to what #74113 ended up solving.
It also has some open design questions IMO, which I don't want to care about for now 😆
ices/56445-2.rs: fixed with errors
ices/60814.rs: fixed with errors
lcnr commentedon Jun 28, 2022
const generics triage
This is part of generic const parameter types. The design work for that is tracked in rust-lang/project-const-generics#28.
unexpected rib kind: ConstGeneric
inlate.rs
#1091431 remaining item