Skip to content

Types without structural equality in const arguments #47

Open
@lcnr

Description

@lcnr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-generic-exprsGeneric const expressionsA-unificationUnifying constants in the type systemC-design-docsCategory: This is part of our design documentationK-behaviorDocument Kind: regarding user visible behaviorP-necessaryPriority: will be needed at some pointS-active

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions