]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/variance-regions-indirect.rs
Auto merge of #22517 - brson:relnotes, r=Gankro
[rust.git] / src / test / compile-fail / variance-regions-indirect.rs
1 // Copyright 2012 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 correctly infer variance for region parameters in
12 // case that involve multiple intricate types.
13 // Try enums too.
14
15 #![feature(rustc_attrs)]
16
17 #[rustc_variance]
18 enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]]
19     Test8A(extern "Rust" fn(&'a isize)),
20     Test8B(&'b [isize]),
21     Test8C(&'b mut &'c str),
22 }
23
24 #[rustc_variance]
25 struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[]]
26     f: Base<'z, 'y, 'x, 'w>
27 }
28
29 #[rustc_variance] // Combine - and + to yield o
30 struct Derived2<'a, 'b:'a, 'c> { //~ ERROR regions=[[o, o, *];[];[]]
31     f: Base<'a, 'a, 'b, 'c>
32 }
33
34 #[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here)
35 struct Derived3<'a:'b, 'b, 'c> { //~ ERROR regions=[[o, -, *];[];[]]
36     f: Base<'a, 'b, 'a, 'c>
37 }
38
39 #[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here)
40 struct Derived4<'a, 'b, 'c:'b> { //~ ERROR regions=[[+, -, o];[];[]]
41     f: Base<'a, 'b, 'c, 'a>
42 }
43
44 fn main() {}