]> git.lizzy.rs Git - rust.git/blob - src/test/ui/variance/variance-trait-bounds.rs
Rollup merge of #92959 - asquared31415:test-non-fn-help, r=estebank
[rust.git] / src / test / ui / variance / variance-trait-bounds.rs
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
7 trait Getter<T> {
8     fn get(&self) -> T;
9 }
10
11 trait Setter<T> {
12     fn get(&self, _: T);
13 }
14
15 #[rustc_variance]
16 struct TestStruct<U,T:Setter<U>> { //~ ERROR [+, +]
17     t: T, u: U
18 }
19
20 #[rustc_variance]
21 enum TestEnum<U,T:Setter<U>> { //~ ERROR [*, +]
22     Foo(T)
23 }
24
25 #[rustc_variance]
26 struct TestContraStruct<U,T:Setter<U>> { //~ ERROR [*, +]
27     t: T
28 }
29
30 #[rustc_variance]
31 struct TestBox<U,T:Getter<U>+Setter<U>> { //~ ERROR [*, +]
32     t: T
33 }
34
35 pub fn main() { }