2020-08-09 06:19:57 +00:00
|
|
|
// Check that functions cannot be used as const parameters.
|
|
|
|
// revisions: full min
|
|
|
|
|
2021-08-30 10:59:53 +02:00
|
|
|
#![cfg_attr(full, feature(adt_const_params))]
|
2020-08-09 06:19:57 +00:00
|
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
2019-10-01 17:55:26 +13:00
|
|
|
|
|
|
|
fn function() -> u32 {
|
|
|
|
17
|
|
|
|
}
|
|
|
|
|
2020-06-12 19:25:14 +02:00
|
|
|
struct Wrapper<const F: fn() -> u32>; //~ ERROR: using function pointers as const generic parameters
|
2019-10-01 17:55:26 +13:00
|
|
|
|
2019-11-18 14:57:23 -05:00
|
|
|
impl<const F: fn() -> u32> Wrapper<F> {
|
2020-06-12 19:25:14 +02:00
|
|
|
//~^ ERROR: using function pointers as const generic parameters
|
2019-10-01 17:55:26 +13:00
|
|
|
fn call() -> u32 {
|
|
|
|
F()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-11-18 14:57:23 -05:00
|
|
|
assert_eq!(Wrapper::<function>::call(), 17);
|
2019-10-02 20:29:16 +13:00
|
|
|
}
|