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