2020-08-09 06:19:57 +00:00
|
|
|
//@ revisions: full min
|
|
|
|
|
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
|
|
|
|
|
|
|
struct Checked<const F: fn(usize) -> bool>;
|
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 not_one(val: usize) -> bool { val != 1 }
|
|
|
|
fn not_two(val: usize) -> bool { val != 2 }
|
|
|
|
|
|
|
|
fn generic_arg<T>(val: T) -> bool { true }
|
|
|
|
|
|
|
|
fn generic<T>(val: usize) -> bool { val != 1 }
|
|
|
|
|
|
|
|
fn main() {
|
2019-11-18 19:57:23 +00:00
|
|
|
let _: Option<Checked<not_one>> = None;
|
|
|
|
let _: Checked<not_one> = Checked::<not_one>;
|
2020-06-12 17:25:14 +00:00
|
|
|
let _: Checked<not_one> = Checked::<not_two>;
|
2019-10-01 04:55:26 +00:00
|
|
|
|
2019-11-18 19:57:23 +00:00
|
|
|
let _ = Checked::<generic_arg>;
|
2019-10-01 04:55:26 +00:00
|
|
|
let _ = Checked::<{generic_arg::<usize>}>;
|
2024-02-09 12:17:55 +00:00
|
|
|
let _ = Checked::<{generic_arg::<u32>}>; //~ ERROR: mismatched types
|
2019-10-01 04:55:26 +00:00
|
|
|
|
2024-02-09 12:17:55 +00:00
|
|
|
let _ = Checked::<generic>; //~ ERROR: type annotations needed
|
2019-10-01 04:55:26 +00:00
|
|
|
let _ = Checked::<{generic::<u16>}>;
|
|
|
|
let _: Checked<{generic::<u16>}> = Checked::<{generic::<u16>}>;
|
2020-06-12 17:25:14 +00:00
|
|
|
let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
|
2019-10-02 07:29:16 +00:00
|
|
|
}
|