]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/assoc-type-const.rs
Rollup merge of #106716 - c410-f3r:rfc-2397-1, r=davidtwco
[rust.git] / tests / 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
7 trait UnwrapItemsExt<'a, const C: usize> {
8     type Iter;
9     fn unwrap_items(self) -> Self::Iter;
10 }
11
12 struct MyStruct<const C: usize> {}
13
14 trait MyTrait<'a, const C: usize> {
15     type MyItem;
16     const MY_CONST: usize;
17 }
18
19 impl<'a, const C: usize> MyTrait<'a, C> for MyStruct<C> {
20     type MyItem = u8;
21     const MY_CONST: usize = C;
22 }
23
24 impl<'a, I, const C: usize> UnwrapItemsExt<'a, C> for I {
25     type Iter = impl MyTrait<'a, C>;
26
27     fn unwrap_items(self) -> Self::Iter {
28         MyStruct::<C> {}
29     }
30 }
31
32 fn main() {}