Constraining generic parameters #23
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
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
Given an impl, the compiler has to be able to decide the generic arguments used by that impl.
Consider the following snippet:
When calling
Weird::<3>::returns_a()
, there is no way to restrict the generic parametersA
orB
so this has to error.If a generic parameter is used by an injective expression, then we could allow this. The most relevant case here are
constructors:
Here it is very clear which
N
we should use givenUsesOption::<{ Some(3) }>
.TODO: blocked on structural equality.
The text was updated successfully, but these errors were encountered: