]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/associated-types-nested-projections.rs
Auto merge of #22517 - brson:relnotes, r=Gankro
[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 use std::slice;
14
15 trait Bound {}
16
17 impl<'a> Bound for &'a int {}
18
19 trait IntoIterator {
20     type Iter: Iterator;
21
22     fn into_iter(self) -> Self::Iter;
23 }
24
25 impl<'a, T> IntoIterator for &'a [T; 3] {
26     type Iter = slice::Iter<'a, T>;
27
28     fn into_iter(self) -> slice::Iter<'a, T> {
29         self.iter()
30     }
31 }
32
33 fn foo<X>(x: X) where
34     X: IntoIterator,
35     <<X as IntoIterator>::Iter as Iterator>::Item: Bound,
36 {
37 }
38
39 fn bar<T, I, X>(x: X) where
40     T: Bound,
41     I: Iterator<Item=T>,
42     X: IntoIterator<Iter=I>,
43 {
44
45 }
46
47 fn main() {
48     foo(&[0, 1, 2]);
49     bar(&[0, 1, 2]);
50 }