-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
fn's can be used as const generics #84238
Comments
The first is definitely intentional. |
The second is a bug, good catch! I misread the issue description at first. This should not work in arrays -- I assume this would be fixed by properly moving to valtrees. |
#![feature(adt_const_params)]
struct B<const F: [fn(); 1]>; still compiles, the issue is that function pointers are currently considered to be structural match. I intend to work on structural equality in the near (not that near) future, going to assign this to myself. @rustbot claim |
Same issue with raw pointers (both #![feature(adt_const_params)]
struct Works<const F: [*mut (); 1]>; // Should not work
struct DoesNotWork<const F: *mut ()>; |
This no longer works: #![feature(adt_const_params)]
struct Works<const F: [*mut (); 1]>; // Should not work Looks like the issue got fixed? We should make sure we have a test though. |
this happens as const generics now relies on |
…_test, r=compiler-errors Add test for adt_const_params Fixes rust-lang#84238 r? `@compiler-errors`
Rollup merge of rust-lang#127243 - BoxyUwU:new_invalid_const_param_ty_test, r=compiler-errors Add test for adt_const_params Fixes rust-lang#84238 r? `@compiler-errors`
The following code fails to compile, because using function pointers as const generics is forbidden:
However, if the function pointer is inside an array, it suddenly compiles:
Is this intentional, or should it also be forbidden?
The text was updated successfully, but these errors were encountered: