]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/type-dependent/issue-70586.rs
Auto merge of #106812 - oli-obk:output_filenames, r=petrochenkov
[rust.git] / tests / ui / const-generics / type-dependent / issue-70586.rs
1 // check-pass
2 use std::marker::PhantomData;
3
4 // This namespace is necessary for the ICE to trigger
5 struct Namespace;
6
7 impl Namespace {
8     pub fn const_chunks_exact<T, const N: usize>() -> ConstChunksExact<'static, T, N> {
9         ConstChunksExact { inner: PhantomData }
10     }
11 }
12
13
14 #[derive(Debug)]
15 pub struct ConstChunksExact<'a, T, const N: usize> {
16     inner:  PhantomData<&'a T>
17 }
18
19 impl <'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> {
20     type Item = &'a [T; N];
21
22     fn next(&mut self) -> Option<Self::Item> {
23         unreachable!()
24     }
25 }
26
27 fn main() {
28     let mut chunks = Namespace::const_chunks_exact::<i32, 3usize>();
29     let _next: &[i32; 3] = chunks.next().unwrap();
30 }