]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/associated-types-normalize-in-bounds-ufcs.rs
Auto merge of #22517 - brson:relnotes, r=Gankro
[rust.git] / src / test / run-pass / associated-types-normalize-in-bounds-ufcs.rs
1 // Copyright 2014 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 normalize associated types that appear in bounds; if
12 // we didn't, the call to `self.split2()` fails to type check.
13
14 struct Splits<'a, T, P>;
15 struct SplitsN<I>;
16
17 trait SliceExt2 {
18     type Item;
19
20     fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P>
21         where P: FnMut(&Self::Item) -> bool;
22     fn splitn2<'a, P>(&'a self, n: uint, pred: P) -> SplitsN<Splits<'a, Self::Item, P>>
23         where P: FnMut(&Self::Item) -> bool;
24 }
25
26 impl<T> SliceExt2 for [T] {
27     type Item = T;
28
29     fn split2<P>(&self, pred: P) -> Splits<T, P> where P: FnMut(&T) -> bool {
30         loop {}
31     }
32
33     fn splitn2<P>(&self, n: uint, pred: P) -> SplitsN<Splits<T, P>> where P: FnMut(&T) -> bool {
34         SliceExt2::split2(self, pred);
35         loop {}
36     }
37 }
38
39 fn main() { }