]> git.proxmox.com Git - rustc.git/blame - src/test/ui/variance/variance-trait-bounds.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / src / test / ui / variance / variance-trait-bounds.rs
CommitLineData
85aaf69f
SL
1#![allow(dead_code)]
2#![feature(rustc_attrs)]
3
4// Check that bounds on type parameters (other than `Self`) do not
5// influence variance.
6
041b39d2 7trait Getter<T> {
85aaf69f
SL
8 fn get(&self) -> T;
9}
10
041b39d2
XL
11trait Setter<T> {
12 fn get(&self, _: T);
85aaf69f
SL
13}
14
15#[rustc_variance]
9e0c209e 16struct TestStruct<U,T:Setter<U>> { //~ ERROR [+, +]
85aaf69f
SL
17 t: T, u: U
18}
19
20#[rustc_variance]
7cac9316 21enum TestEnum<U,T:Setter<U>> { //~ ERROR [*, +]
85aaf69f
SL
22 Foo(T)
23}
24
85aaf69f 25#[rustc_variance]
9e0c209e 26struct TestContraStruct<U,T:Setter<U>> { //~ ERROR [*, +]
85aaf69f
SL
27 t: T
28}
29
30#[rustc_variance]
9e0c209e 31struct TestBox<U,T:Getter<U>+Setter<U>> { //~ ERROR [*, +]
85aaf69f
SL
32 t: T
33}
34
35pub fn main() { }