]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/associated-types-normalize-in-bounds-ufcs.rs
8617750ca538ea02472b33bd0e77781960fba9df
[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 use std::marker::PhantomData;
15
16 struct Splits<'a, T:'a, P>(PhantomData<(&'a T, P)>);
17 struct SplitsN<I>(PhantomData<I>);
18
19 trait SliceExt2 {
20     type Item;
21
22     fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P>
23         where P: FnMut(&Self::Item) -> bool;
24     fn splitn2<'a, P>(&'a self, n: u32, pred: P) -> SplitsN<Splits<'a, Self::Item, P>>
25         where P: FnMut(&Self::Item) -> bool;
26 }
27
28 impl<T> SliceExt2 for [T] {
29     type Item = T;
30
31     fn split2<P>(&self, pred: P) -> Splits<T, P> where P: FnMut(&T) -> bool {
32         loop {}
33     }
34
35     fn splitn2<P>(&self, n: u32, pred: P) -> SplitsN<Splits<T, P>> where P: FnMut(&T) -> bool {
36         SliceExt2::split2(self, pred);
37         loop {}
38     }
39 }
40
41 fn main() { }