]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/fn-const-param-call.rs
Auto merge of #104334 - compiler-errors:ufcs-sugg-wrong-def-id, r=estebank
[rust.git] / src / test / ui / const-generics / fn-const-param-call.rs
1 // Check that functions cannot be used as const parameters.
2 // revisions: full min
3
4 #![cfg_attr(full, feature(adt_const_params))]
5 #![cfg_attr(full, allow(incomplete_features))]
6
7 fn function() -> u32 {
8     17
9 }
10
11 struct Wrapper<const F: fn() -> u32>; //~ ERROR: using function pointers as const generic parameters
12
13 impl<const F: fn() -> u32> Wrapper<F> {
14 //~^ ERROR: using function pointers as const generic parameters
15     fn call() -> u32 {
16         F()
17     }
18 }
19
20 fn main() {
21     assert_eq!(Wrapper::<function>::call(), 17);
22 }