]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/associated-types-nested-projections.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / run-pass / associated-types-nested-projections.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Test that we can resolve nested projection types. Issue #20666.
12
13 // pretty-expanded FIXME #23616
14
15 #![feature(core)]
16
17 use std::slice;
18
19 trait Bound {}
20
21 impl<'a> Bound for &'a i32 {}
22
23 trait IntoIterator {
24     type Iter: Iterator;
25
26     fn into_iter(self) -> Self::Iter;
27 }
28
29 impl<'a, T> IntoIterator for &'a [T; 3] {
30     type Iter = slice::Iter<'a, T>;
31
32     fn into_iter(self) -> slice::Iter<'a, T> {
33         self.iter()
34     }
35 }
36
37 fn foo<X>(x: X) where
38     X: IntoIterator,
39     <<X as IntoIterator>::Iter as Iterator>::Item: Bound,
40 {
41 }
42
43 fn bar<T, I, X>(x: X) where
44     T: Bound,
45     I: Iterator<Item=T>,
46     X: IntoIterator<Iter=I>,
47 {
48
49 }
50
51 fn main() {
52     foo(&[0, 1, 2]);
53     bar(&[0, 1, 2]);
54 }