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