]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/variance-regions-indirect.rs
New upstream version 1.13.0+dfsg1
[rustc.git] / src / test / compile-fail / variance-regions-indirect.rs
CommitLineData
1a4d82fc
JJ
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
85aaf69f
SL
15#![feature(rustc_attrs)]
16
1a4d82fc 17#[rustc_variance]
9e0c209e 18enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR [+, -, o, *]
85aaf69f 19 //~^ ERROR parameter `'d` is never used
1a4d82fc
JJ
20 Test8A(extern "Rust" fn(&'a isize)),
21 Test8B(&'b [isize]),
22 Test8C(&'b mut &'c str),
23}
24
25#[rustc_variance]
9e0c209e 26struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR [*, o, -, +]
85aaf69f 27 //~^ ERROR parameter `'w` is never used
1a4d82fc
JJ
28 f: Base<'z, 'y, 'x, 'w>
29}
30
31#[rustc_variance] // Combine - and + to yield o
9e0c209e 32struct Derived2<'a, 'b:'a, 'c> { //~ ERROR [o, o, *]
85aaf69f 33 //~^ ERROR parameter `'c` is never used
1a4d82fc
JJ
34 f: Base<'a, 'a, 'b, 'c>
35}
36
37#[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here)
9e0c209e 38struct Derived3<'a:'b, 'b, 'c> { //~ ERROR [o, -, *]
85aaf69f 39 //~^ ERROR parameter `'c` is never used
1a4d82fc
JJ
40 f: Base<'a, 'b, 'a, 'c>
41}
42
43#[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here)
9e0c209e 44struct Derived4<'a, 'b, 'c:'b> { //~ ERROR [+, -, o]
1a4d82fc
JJ
45 f: Base<'a, 'b, 'c, 'a>
46}
47
48fn main() {}