//@ check-pass // Basic usage patterns of free & associated generic const items. #![feature(generic_const_items)] #![allow(incomplete_features)] fn main() { const NULL: Option = None::; const NOTHING: Option = None; // arg inferred let _ = NOTHING::; let _: Option = NULL; // arg inferred const IDENTITY: u64 = X; const COUNT: u64 = IDENTITY::<48>; const AMOUNT: u64 = IDENTITY::; const NUMBER: u64 = IDENTITY::<{ AMOUNT * 2 }>; let _ = NUMBER; let _ = IDENTITY::<0>; let _ = match 0 { IDENTITY::<1> => 2, IDENTITY::<{ 1 + 1 }> => 4, _ => 0, }; const CREATE: I = I::PROOF; let _ = CREATE::; let _: u64 = CREATE; // arg inferred let _ = <() as Main>::MAKE::; let _: (u64, u64) = <()>::MAKE; // args inferred } pub fn usage<'any>() { const REGION_POLY<'a>: &'a () = &(); let _: &'any () = REGION_POLY::<'any>; let _: &'any () = REGION_POLY::<'_>; let _: &'static () = REGION_POLY; } trait Main { type Output; const MAKE: Self::Output; } impl Main for () { type Output = (O, I); const MAKE: Self::Output = (O::PROOF, I::PROOF); } trait Inhabited { const PROOF: Self; } impl Inhabited for u64 { const PROOF: Self = 512; }