You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Const contexts that are used as parts of types (array type and repeat length expressions as well as const generic arguments) can only make restricted use of surrounding generic type and lifetime parameters.
We should document what these restrictions are precisely.
Here's an example of what doesn't work:
fnfoo<constC:usize>(){let _ = [();const{C + 1}];//~^ ERROR generic parameters may not be used in const operations}
Similarly:
traitTr{constC:usize;}implTrfor(){constC:usize = 0;}fnfoo<T:Tr>(){let _ = [();const{T::C}];//~^ ERROR constant expression depends on a generic parameter}
We should probably also emit more specific errors -- it is not wrong for "constant expression [to depend] on a generic parameter", it's just wrong in this specific case where that expression occurs in a type.
Also, strange that the two examples above lead to different errors that say the same thing in different words -- they must be caught by different checks, somehow?
As raised here:
...related to the language:
We should document what these restrictions are precisely.
Here's an example of what doesn't work:
Similarly:
cc @RalfJung @ehuss @BoxyUwU
The text was updated successfully, but these errors were encountered: