]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/variance-regions-indirect.rs
Changed issue number to 36105
[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     //~^ ERROR parameter `'d` is never used
20     Test8A(extern "Rust" fn(&'a isize)),
21     Test8B(&'b [isize]),
22     Test8C(&'b mut &'c str),
23 }
24
25 #[rustc_variance]
26 struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[*, o, -, +]
27     //~^ ERROR parameter `'w` is never used
28     f: Base<'z, 'y, 'x, 'w>
29 }
30
31 #[rustc_variance] // Combine - and + to yield o
32 struct Derived2<'a, 'b:'a, 'c> { //~ ERROR regions=[o, o, *]
33     //~^ ERROR parameter `'c` is never used
34     f: Base<'a, 'a, 'b, 'c>
35 }
36
37 #[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here)
38 struct Derived3<'a:'b, 'b, 'c> { //~ ERROR regions=[o, -, *]
39     //~^ ERROR parameter `'c` is never used
40     f: Base<'a, 'b, 'a, 'c>
41 }
42
43 #[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here)
44 struct Derived4<'a, 'b, 'c:'b> { //~ ERROR regions=[+, -, o]
45     f: Base<'a, 'b, 'c, 'a>
46 }
47
48 fn main() {}