]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/fn-const-param-infer.rs
Rollup merge of #74333 - poliorcetics:std-alloc-unsafe-op-in-unsafe-fn, r=LukasKalbertodt
[rust.git] / src / test / ui / const-generics / fn-const-param-infer.rs
1 #![feature(const_generics)]
2 //~^ WARN the feature `const_generics` is incomplete
3
4 struct Checked<const F: fn(usize) -> bool>;
5 //~^ ERROR: using function pointers as const generic parameters
6
7 fn not_one(val: usize) -> bool { val != 1 }
8 fn not_two(val: usize) -> bool { val != 2 }
9
10 fn generic_arg<T>(val: T) -> bool { true }
11
12 fn generic<T>(val: usize) -> bool { val != 1 }
13
14 fn main() {
15     let _: Option<Checked<not_one>> = None;
16     let _: Checked<not_one> = Checked::<not_one>;
17     let _: Checked<not_one> = Checked::<not_two>;
18
19     let _ = Checked::<generic_arg>;
20     let _ = Checked::<{generic_arg::<usize>}>;
21     let _ = Checked::<{generic_arg::<u32>}>;
22
23     let _ = Checked::<generic>;
24     let _ = Checked::<{generic::<u16>}>;
25     let _: Checked<{generic::<u16>}> = Checked::<{generic::<u16>}>;
26     let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
27 }