]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/higher-lifetime-bounds.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.
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.
11 #![allow(dead_code, non_camel_case_types)]
13 // Test that bounds on higher-kinded lifetime binders are rejected.
18 f
: for<'xa
, 'xb
: 'xa
+'xa
> fn(&'xa
i32, &'xb
i32) -> &'xa
i32)
19 //~^ ERROR lifetime bounds cannot be used in this context
21 // If the bound in f's type would matter, the call below would (have to)
26 fn bar2
<'a
, 'b
, F
: for<'xa
, 'xb
: 'xa
> Fn(&'xa
i32, &'xb
i32) -> &'xa
i32>(
27 //~^ ERROR lifetime bounds cannot be used in this context
32 // If the bound in f's type would matter, the call below would (have to)
41 where F
: for<'xa
, 'xb
: 'xa
> Fn(&'xa
i32, &'xb
i32) -> &'xa
i32
42 //~^ ERROR lifetime bounds cannot be used in this context
44 // If the bound in f's type would matter, the call below would (have to)
53 where for<'xa
, 'xb
: 'xa
> F
: Fn(&'xa
i32, &'xb
i32) -> &'xa
i32
54 //~^ ERROR lifetime bounds cannot be used in this context
56 // If the bound in f's type would matter, the call below would (have to)
61 struct S1
<F
: for<'xa
, 'xb
: 'xa
> Fn(&'xa
i32, &'xb
i32) -> &'xa
i32>(F
);
62 //~^ ERROR lifetime bounds cannot be used in this context
63 struct S2
<F
>(F
) where F
: for<'xa
, 'xb
: 'xa
> Fn(&'xa
i32, &'xb
i32) -> &'xa
i32;
64 //~^ ERROR lifetime bounds cannot be used in this context
65 struct S3
<F
>(F
) where for<'xa
, 'xb
: 'xa
> F
: Fn(&'xa
i32, &'xb
i32) -> &'xa
i32;
66 //~^ ERROR lifetime bounds cannot be used in this context
68 struct S_fnty(for<'xa
, 'xb
: 'xa
> fn(&'xa
i32, &'xb
i32) -> &'xa
i32);
69 //~^ ERROR lifetime bounds cannot be used in this context
71 type T1
= Box
<for<'xa
, 'xb
: 'xa
> Fn(&'xa
i32, &'xb
i32) -> &'xa
i32>;
72 //~^ ERROR lifetime bounds cannot be used in this context
75 let _
: Option
<for<'xa
, 'xb
: 'xa
> fn(&'xa
i32, &'xb
i32) -> &'xa
i32> = None
;
76 //~^ ERROR lifetime bounds cannot be used in this context
77 let _
: Option
<Box
<for<'xa
, 'xb
: 'xa
> Fn(&'xa
i32, &'xb
i32) -> &'xa
i32>> = None
;
78 //~^ ERROR lifetime bounds cannot be used in this context