]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-type-bounds/fn-wrap-apit.rs
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
[rust.git] / src / test / ui / associated-type-bounds / fn-wrap-apit.rs
1 // run-pass
2 // aux-build:fn-aux.rs
3
4 #![feature(associated_type_bounds)]
5 #![allow(dead_code)]
6
7 extern crate fn_aux;
8
9 use fn_aux::*;
10
11 // ATB, APIT + Wrap:
12
13 struct Wrap<T>(T);
14
15 fn wrap_apit_bound(beta: Wrap<impl Beta<Gamma: Alpha>>) -> usize {
16     desugared_bound(beta.0)
17 }
18
19 fn wrap_apit_bound_region(beta: Wrap<impl Beta<Gamma: 'static>>) -> usize {
20     desugared_bound_region(beta.0)
21 }
22
23 fn wrap_apit_bound_multi(
24     beta: Wrap<impl Copy + Beta<Gamma: Alpha + 'static + Delta>>
25 ) -> usize {
26     desugared_bound_multi(beta.0)
27 }
28
29 fn wrap_apit_bound_region_forall(
30     beta: Wrap<impl Beta<Gamma: Copy + for<'a> Epsilon<'a>>>
31 ) -> usize {
32     desugared_bound_region_forall(beta.0)
33 }
34
35 fn wrap_apit_bound_region_forall2(
36     beta: Wrap<impl Beta<Gamma: Copy + for<'a> Epsilon<'a, Zeta: Eta>>>
37 ) -> usize {
38     desugared_bound_region_forall2(beta.0)
39 }
40
41 fn wrap_apit_bound_nested(
42     beta: Wrap<impl Beta<Gamma: Copy + Alpha + Beta<Gamma: Delta>>>
43 ) -> usize {
44     desugared_bound_nested(beta.0)
45 }
46
47 fn wrap_apit_bound_nested2(
48     beta: Wrap<impl Beta<Gamma = impl Copy + Alpha + Beta<Gamma: Delta>>>
49 ) -> usize {
50     desugared_bound_nested(beta.0)
51 }
52
53 fn main() {
54     let beta = BetaType;
55     let _gamma = beta.gamma();
56
57     assert_eq!(42, wrap_apit_bound(Wrap(beta)));
58     assert_eq!(24, wrap_apit_bound_region(Wrap(beta)));
59     assert_eq!(42 + 24 + 1337, wrap_apit_bound_multi(Wrap(beta)));
60     assert_eq!(7331 * 2, wrap_apit_bound_region_forall(Wrap(beta)));
61     // FIXME: requires lazy normalization.
62     // assert_eq!(7331 * 2, wrap_apit_bound_region_forall2(Wrap(beta)));
63     assert_eq!(42 + 1337, wrap_apit_bound_nested(Wrap(beta)));
64     assert_eq!(42 + 1337, wrap_apit_bound_nested2(Wrap(beta)));
65 }