]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/fn-const-param-call.rs
Merge branch 'master' into stabilize-vecdeque-make_contiguous
[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(const_generics))]
5 #![cfg_attr(full, allow(incomplete_features))]
6 #![cfg_attr(min, feature(min_const_generics))]
7
8 fn function() -> u32 {
9     17
10 }
11
12 struct Wrapper<const F: fn() -> u32>; //~ ERROR: using function pointers as const generic parameters
13
14 impl<const F: fn() -> u32> Wrapper<F> {
15 //~^ ERROR: using function pointers as const generic parameters
16     fn call() -> u32 {
17         F()
18     }
19 }
20
21 fn main() {
22     assert_eq!(Wrapper::<function>::call(), 17);
23 }