Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types without structural equality in const arguments #47

Open
lcnr opened this issue May 20, 2022 · 0 comments
Open

Types without structural equality in const arguments #47

lcnr opened this issue May 20, 2022 · 0 comments
Labels
A-generic-exprs Generic const expressions A-unification Unifying constants in the type system C-design-docs Category: This is part of our design documentation K-behavior Document Kind: regarding user visible behavior P-necessary Priority: will be needed at some point S-active

Comments

@lcnr
Copy link
Contributor

lcnr commented May 20, 2022

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.

@lcnr lcnr added C-design-docs Category: This is part of our design documentation K-behavior Document Kind: regarding user visible behavior P-necessary Priority: will be needed at some point S-active A-generic-exprs Generic const expressions A-unification Unifying constants in the type system labels May 20, 2022
@lcnr lcnr changed the title Types without structural equality in const parameters Types without structural equality in const arguments Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-generic-exprs Generic const expressions A-unification Unifying constants in the type system C-design-docs Category: This is part of our design documentation K-behavior Document Kind: regarding user visible behavior P-necessary Priority: will be needed at some point S-active
Projects
None yet
Development

No branches or pull requests

1 participant