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