]> git.proxmox.com Git - rustc.git/blob - src/test/ui/type-alias-impl-trait/assoc-type-const.rs
5db677d82e2663ae97bb51764fe3bb5b8f2220f7
[rustc.git] / src / test / ui / type-alias-impl-trait / assoc-type-const.rs
1 // Tests that we properly detect defining usages when using
2 // const generics in an associated opaque type
3 // check-pass
4
5 #![feature(type_alias_impl_trait)]
6 #![feature(const_generics)]
7 //~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
8
9 trait UnwrapItemsExt<const C: usize> {
10 type Iter;
11 fn unwrap_items(self) -> Self::Iter;
12 }
13
14 struct MyStruct<const C: usize> {}
15
16 trait MyTrait<'a, const C: usize> {
17 type MyItem;
18 const MY_CONST: usize;
19 }
20
21 impl<'a, const C: usize> MyTrait<'a, {C}> for MyStruct<{C}> {
22 type MyItem = u8;
23 const MY_CONST: usize = C;
24 }
25
26 impl<'a, I, const C: usize> UnwrapItemsExt<{C}> for I
27 where
28 {
29 type Iter = impl MyTrait<'a, {C}>;
30
31 fn unwrap_items(self) -> Self::Iter {
32 MyStruct::<{C}> {}
33 }
34 }
35
36 fn main() {}