2024-07-14 12:38:51 +00:00
|
|
|
//@ revisions: min adt_const_params full
|
2020-08-09 06:19:57 +00:00
|
|
|
|
2024-07-14 12:38:51 +00:00
|
|
|
#![cfg_attr(full, feature(adt_const_params, unsized_const_params))]
|
2020-08-09 06:19:57 +00:00
|
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
2024-07-14 12:38:51 +00:00
|
|
|
#![cfg_attr(adt_const_params, feature(adt_const_params))]
|
|
|
|
#![cfg_attr(adt_const_params, 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
|
|
|
|
2024-07-14 12:38:51 +00:00
|
|
|
fn not_one(val: usize) -> bool {
|
|
|
|
val != 1
|
|
|
|
}
|
|
|
|
fn not_two(val: usize) -> bool {
|
|
|
|
val != 2
|
|
|
|
}
|
2019-10-01 04:55:26 +00:00
|
|
|
|
2024-07-14 12:38:51 +00:00
|
|
|
fn generic_arg<T>(val: T) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2019-10-01 04:55:26 +00:00
|
|
|
|
2024-07-14 12:38:51 +00:00
|
|
|
fn generic<T>(val: usize) -> bool {
|
|
|
|
val != 1
|
|
|
|
}
|
2019-10-01 04:55:26 +00:00
|
|
|
|
|
|
|
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>;
|
2024-07-14 12:38:51 +00:00
|
|
|
let _ = Checked::<{ generic_arg::<usize> }>;
|
|
|
|
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
|
2024-07-14 12:38:51 +00:00
|
|
|
let _ = Checked::<{ generic::<u16> }>;
|
|
|
|
let _: Checked<{ generic::<u16> }> = Checked::<{ generic::<u16> }>;
|
|
|
|
let _: Checked<{ generic::<u32> }> = Checked::<{ generic::<u16> }>;
|
2019-10-02 07:29:16 +00:00
|
|
|
}
|