about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2017-06-02 22:05:41 +0300
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2017-06-27 16:39:58 +0300
commita9d4069975af1ef0192984ad033fd30ceca4fa78 (patch)
treeb17f4c1bc8ec65d1192c4f1305bc7a0c231347ab /src/test
parent33ecf72e8e26b5bf5449ae27297e83c9f78aa3ad (diff)
downloadrust-a9d4069975af1ef0192984ad033fd30ceca4fa78.tar.gz
rust-a9d4069975af1ef0192984ad033fd30ceca4fa78.zip
rustc_typeck: support functions in variance computation.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/variance-region-bounds.rs25
-rw-r--r--src/test/compile-fail/variance-trait-bounds.rs20
-rw-r--r--src/test/compile-fail/variance-types-bounds.rs27
3 files changed, 4 insertions, 68 deletions
diff --git a/src/test/compile-fail/variance-region-bounds.rs b/src/test/compile-fail/variance-region-bounds.rs
deleted file mode 100644
index 41d204a541b..00000000000
--- a/src/test/compile-fail/variance-region-bounds.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Check that `T:'a` is contravariant in T.
-
-#![feature(rustc_attrs)]
-
-#[rustc_variance]
-trait Foo: 'static { //~ ERROR [o]
-}
-
-#[rustc_variance]
-trait Bar<T> { //~ ERROR [o, o]
-    fn do_it(&self)
-        where T: 'static;
-}
-
-fn main() { }
diff --git a/src/test/compile-fail/variance-trait-bounds.rs b/src/test/compile-fail/variance-trait-bounds.rs
index 58fb785c48c..9b88e38e085 100644
--- a/src/test/compile-fail/variance-trait-bounds.rs
+++ b/src/test/compile-fail/variance-trait-bounds.rs
@@ -14,13 +14,11 @@
 // Check that bounds on type parameters (other than `Self`) do not
 // influence variance.
 
-#[rustc_variance]
-trait Getter<T> { //~ ERROR [o, o]
+trait Getter<T> {
     fn get(&self) -> T;
 }
 
-#[rustc_variance]
-trait Setter<T> { //~ ERROR [o, o]
+trait Setter<T> {
     fn get(&self, T);
 }
 
@@ -35,20 +33,6 @@ enum TestEnum<U,T:Setter<U>> { //~ ERROR [*, +]
 }
 
 #[rustc_variance]
-trait TestTrait<U,T:Setter<U>> { //~ ERROR [o, o, o]
-    fn getter(&self, u: U) -> T;
-}
-
-#[rustc_variance]
-trait TestTrait2<U> : Getter<U> { //~ ERROR [o, o]
-}
-
-#[rustc_variance]
-trait TestTrait3<U> { //~ ERROR [o, o]
-    fn getter<T:Getter<U>>(&self);
-}
-
-#[rustc_variance]
 struct TestContraStruct<U,T:Setter<U>> { //~ ERROR [*, +]
     t: T
 }
diff --git a/src/test/compile-fail/variance-types-bounds.rs b/src/test/compile-fail/variance-types-bounds.rs
index 2df94cc907a..5075dd2ceed 100644
--- a/src/test/compile-fail/variance-types-bounds.rs
+++ b/src/test/compile-fail/variance-types-bounds.rs
@@ -36,38 +36,15 @@ struct TestIndirect2<A:'static, B:'static> { //~ ERROR [o, o]
     m: TestMut<B, A>
 }
 
-#[rustc_variance]
-trait Getter<A> { //~ ERROR [o, o]
+trait Getter<A> {
     fn get(&self) -> A;
 }
 
-#[rustc_variance]
-trait Setter<A> { //~ ERROR [o, o]
-    fn set(&mut self, a: A);
-}
-
-#[rustc_variance]
-trait GetterSetter<A> { //~ ERROR [o, o]
-    fn get(&self) -> A;
+trait Setter<A> {
     fn set(&mut self, a: A);
 }
 
 #[rustc_variance]
-trait GetterInTypeBound<A> { //~ ERROR [o, o]
-    // Here, the use of `A` in the method bound *does* affect
-    // variance.  Think of it as if the method requested a dictionary
-    // for `T:Getter<A>`.  Since this dictionary is an input, it is
-    // contravariant, and the Getter is covariant w/r/t A, yielding an
-    // overall contravariant result.
-    fn do_it<T:Getter<A>>(&self);
-}
-
-#[rustc_variance]
-trait SetterInTypeBound<A> { //~ ERROR [o, o]
-    fn do_it<T:Setter<A>>(&self);
-}
-
-#[rustc_variance]
 struct TestObject<A, R> { //~ ERROR [o, o]
     n: Box<Setter<A>+Send>,
     m: Box<Getter<R>+Send>,