Open
Description
What is this
This is a design document for const generics. Any discussions about its content should be on zulip. The conclusions of these discussions should then be edited back into this issue. Please do not post any comments directly in this issue.
Content
When building an abstract representation for a constant, we have to decide on how to deal with variables/temporaries whose type does not have structural equality (#29). We definitely cannot partially evaluate constants up to that point.
Examples
const fn mk_raw<const N: usize>() -> *const usize {
&N
}
const fn take_raw(x: *const usize) -> usize {
unsafe { *x }
}
fn foo<const N: usize>() -> [u8; take_raw(mk_raw::<N>())] {
[0; take_raw(mk_raw::<N>())]
}
We probably should deal with this by emitting an error during abstract const building when encountering a value which does not have structural equality.