]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/hrtb-higher-ranker-supertraits.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / hrtb-higher-ranker-supertraits.rs
CommitLineData
1a4d82fc
JJ
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 a trait (`Bar`) with a higher-ranked supertrait.
12
13trait Foo<'tcx>
14{
15 fn foo(&'tcx self) -> &'tcx isize;
16}
17
18trait Bar<'ccx>
19 : for<'tcx> Foo<'tcx>
20{
21 fn bar(&'ccx self) -> &'ccx isize;
22}
23
24fn want_foo_for_some_tcx<'x,F>(f: &'x F)
25 where F : Foo<'x>
26{
27 want_foo_for_some_tcx(f);
54a0048b 28 want_foo_for_any_tcx(f); //~ ERROR E0277
1a4d82fc
JJ
29}
30
31fn want_foo_for_any_tcx<F>(f: &F)
32 where F : for<'tcx> Foo<'tcx>
33{
34 want_foo_for_some_tcx(f);
35 want_foo_for_any_tcx(f);
36}
37
38fn want_bar_for_some_ccx<'x,B>(b: &B)
39 where B : Bar<'x>
40{
41 want_foo_for_some_tcx(b);
42 want_foo_for_any_tcx(b);
43
44 want_bar_for_some_ccx(b);
54a0048b 45 want_bar_for_any_ccx(b); //~ ERROR E0277
1a4d82fc
JJ
46}
47
48fn want_bar_for_any_ccx<B>(b: &B)
49 where B : for<'ccx> Bar<'ccx>
50{
51 want_foo_for_some_tcx(b);
52 want_foo_for_any_tcx(b);
53
54 want_bar_for_some_ccx(b);
55 want_bar_for_any_ccx(b);
56}
57
58fn main() {}