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