]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variance/variance-trait-bounds.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / variance / variance-trait-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.
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 #![allow(dead_code)]
12 #![feature(rustc_attrs)]
13
14 // Check that bounds on type parameters (other than `Self`) do not
15 // influence variance.
16
17 trait Getter<T> {
18     fn get(&self) -> T;
19 }
20
21 trait Setter<T> {
22     fn get(&self, _: T);
23 }
24
25 #[rustc_variance]
26 struct TestStruct<U,T:Setter<U>> { //~ ERROR [+, +]
27     t: T, u: U
28 }
29
30 #[rustc_variance]
31 enum TestEnum<U,T:Setter<U>> { //~ ERROR [*, +]
32     Foo(T)
33 }
34
35 #[rustc_variance]
36 struct TestContraStruct<U,T:Setter<U>> { //~ ERROR [*, +]
37     t: T
38 }
39
40 #[rustc_variance]
41 struct TestBox<U,T:Getter<U>+Setter<U>> { //~ ERROR [*, +]
42     t: T
43 }
44
45 pub fn main() { }