#![allow(dead_code)] #![feature(rustc_attrs)] use std::cell::Cell; // Check that a type parameter which is only used in a trait bound is // not considered bivariant. #[rustc_variance] struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR [-, o, o] t: &'a mut (A,B) } #[rustc_variance] struct InvariantCell { //~ ERROR [o] t: Cell } #[rustc_variance] struct InvariantIndirect { //~ ERROR [o] t: InvariantCell } #[rustc_variance] struct Covariant { //~ ERROR [+] t: A, u: fn() -> A } #[rustc_variance] struct Contravariant { //~ ERROR [-] t: fn(A) } #[rustc_variance] enum Enum { //~ ERROR [+, -, o] Foo(Covariant), Bar(Contravariant), Zed(Covariant,Contravariant) } pub fn main() { }