-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Generic patterns and generic array lengths can call const fn with impossible generics #147721
Copy link
Copy link
Open
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-arrayArea: `[T; N]`Area: `[T; N]`A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
I expected the above code to not execute the panic, either at compile time or run time, since there is no
Tthat implementsNotImplemented. Instead, I got the following compiler error:Note that the code compiles fine if I make
fn lolreturn a value normally instead of panicking.Also note that the code gives a reasonable compile error if I make
fn lolreturnsize_of::<T>()Error with `size_of::()`
Using an array length instead of a pattern also runs into a similar issue:
Code and error using array length
Meta
Reproducible on the playground with version
1.92.0-nightly (2025-10-13 4b94758d2ba7d0ef71cc)