]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/fn-const-param-infer.rs
Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
[rust.git] / src / test / ui / const-generics / fn-const-param-infer.rs
1 // revisions: full min
2
3 #![cfg_attr(full, feature(const_generics))]
4 #![cfg_attr(full, allow(incomplete_features))]
5 #![cfg_attr(min, feature(min_const_generics))]
6
7 struct Checked<const F: fn(usize) -> bool>;
8 //~^ ERROR: using function pointers as const generic parameters
9
10 fn not_one(val: usize) -> bool { val != 1 }
11 fn not_two(val: usize) -> bool { val != 2 }
12
13 fn generic_arg<T>(val: T) -> bool { true }
14
15 fn generic<T>(val: usize) -> bool { val != 1 }
16
17 fn main() {
18     let _: Option<Checked<not_one>> = None;
19     let _: Checked<not_one> = Checked::<not_one>;
20     let _: Checked<not_one> = Checked::<not_two>;
21
22     let _ = Checked::<generic_arg>;
23     let _ = Checked::<{generic_arg::<usize>}>;
24     let _ = Checked::<{generic_arg::<u32>}>;
25
26     let _ = Checked::<generic>;
27     let _ = Checked::<{generic::<u16>}>;
28     let _: Checked<{generic::<u16>}> = Checked::<{generic::<u16>}>;
29     let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
30 }