2020-08-09 06:19:57 +00:00
|
|
|
// Check that functions cannot be used as const parameters.
|
2024-02-16 20:02:50 +00:00
|
|
|
//@ revisions: full min
|
2020-08-09 06:19:57 +00:00
|
|
|
|
2021-08-30 08:59:53 +00: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 04:55:26 +00:00
|
|
|
|
|
|
|
fn function() -> u32 {
|
|
|
|
17
|
|
|
|
}
|
|
|
|
|
2020-06-12 17:25:14 +00:00
|
|
|
struct Wrapper<const F: fn() -> u32>; //~ ERROR: using function pointers as const generic parameters
|
2019-10-01 04:55:26 +00:00
|
|
|
|
2019-11-18 19:57:23 +00:00
|
|
|
impl<const F: fn() -> u32> Wrapper<F> {
|
2020-06-12 17:25:14 +00:00
|
|
|
//~^ ERROR: using function pointers as const generic parameters
|
2019-10-01 04:55:26 +00:00
|
|
|
fn call() -> u32 {
|
|
|
|
F()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-11-18 19:57:23 +00:00
|
|
|
assert_eq!(Wrapper::<function>::call(), 17);
|
2019-10-02 07:29:16 +00:00
|
|
|
}
|