about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-11-19 10:47:34 -0500
committerNiko Matsakis <niko@alum.mit.edu>2019-01-02 17:35:06 -0500
commit1db7193162dc1058c11a0eb920bef91434bfe31c (patch)
tree18cfd7c1db47f1c44c2d428dc022f058d8a5ebd4
parentcf2f7cccb4fc170cd395f47569e8280e7081bf25 (diff)
downloadrust-1db7193162dc1058c11a0eb920bef91434bfe31c.tar.gz
rust-1db7193162dc1058c11a0eb920bef91434bfe31c.zip
address tmandry nits
-rw-r--r--src/test/ui/coherence/coherence-subtyping.rs32
-rw-r--r--src/test/ui/coherence/coherence-subtyping.stderr30
-rw-r--r--src/test/ui/hrtb/hrtb-exists-forall-fn.rs13
-rw-r--r--src/test/ui/hrtb/hrtb-exists-forall-fn.stderr2
4 files changed, 14 insertions, 63 deletions
diff --git a/src/test/ui/coherence/coherence-subtyping.rs b/src/test/ui/coherence/coherence-subtyping.rs
index 2ac91560178..fb9a7fbf7ab 100644
--- a/src/test/ui/coherence/coherence-subtyping.rs
+++ b/src/test/ui/coherence/coherence-subtyping.rs
@@ -1,40 +1,14 @@
 // Test that two distinct impls which match subtypes of one another
 // yield coherence errors (or not) depending on the variance.
 
-trait Contravariant {
+trait TheTrait {
     fn foo(&self) { }
 }
 
-impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
+impl TheTrait for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
 }
 
-impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
-    //~^ ERROR
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-trait Covariant {
-    fn foo(&self) { }
-}
-
-impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
-}
-
-impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
-    //~^ ERROR
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-trait Invariant {
-    fn foo(&self) { }
-}
-
-impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
-}
-
-impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
+impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
     //~^ ERROR
 }
 
diff --git a/src/test/ui/coherence/coherence-subtyping.stderr b/src/test/ui/coherence/coherence-subtyping.stderr
index eb68768eed0..1f9b2cb6fdf 100644
--- a/src/test/ui/coherence/coherence-subtyping.stderr
+++ b/src/test/ui/coherence/coherence-subtyping.stderr
@@ -1,30 +1,12 @@
-error[E0119]: conflicting implementations of trait `Contravariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
+error[E0119]: conflicting implementations of trait `TheTrait` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
   --> $DIR/coherence-subtyping.rs:11:1
    |
-LL | impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
-   | -------------------------------------------------------------- first implementation here
+LL | impl TheTrait for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
+   | --------------------------------------------------------- first implementation here
 ...
-LL | impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
+LL | impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
 
-error[E0119]: conflicting implementations of trait `Covariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
-  --> $DIR/coherence-subtyping.rs:24:1
-   |
-LL | impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
-   | ---------------------------------------------------------- first implementation here
-...
-LL | impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
-
-error[E0119]: conflicting implementations of trait `Invariant` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`:
-  --> $DIR/coherence-subtyping.rs:37:1
-   |
-LL | impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 {
-   | ---------------------------------------------------------- first implementation here
-...
-LL | impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8`
-
-error: aborting due to 3 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.rs b/src/test/ui/hrtb/hrtb-exists-forall-fn.rs
index 24182d76b35..828331cb950 100644
--- a/src/test/ui/hrtb/hrtb-exists-forall-fn.rs
+++ b/src/test/ui/hrtb/hrtb-exists-forall-fn.rs
@@ -3,21 +3,16 @@
 // In particular, we test this pattern in trait solving, where it is not connected
 // to any part of the source code.
 
-trait Trait<T> {}
-
 fn foo<'a>() -> fn(&'a u32) {
     panic!()
 }
 
 fn main() {
-    // Here, proving that `(): Trait<for<'b> fn(&'b u32)>` uses the impl:
+    // Here, proving that `fn(&'a u32) <: for<'b> fn(&'b u32)`:
     //
-    // - The impl provides the clause `forall<'a> { (): Trait<fn(&'a u32)> }`
-    // - We instantiate `'a` existentially to get `(): Trait<fn(&?a u32)>`
-    // - We unify `fn(&?a u32)` with `for<'b> fn(&'b u32)`
-    //   - This requires (among other things) instantiating `'b` universally,
-    //     yielding `fn(&!b u32)`, in a fresh universe U1
-    //   - So we get `?a = !b` but the universe U0 assigned to `?a` cannot name `!b`.
+    // - instantiates `'b` with a placeholder `!b`,
+    // - requires that `&!b u32 <: &'a u32` and hence that `!b: 'a`,
+    // - but we can never know this.
 
     let _: for<'b> fn(&'b u32) = foo(); //~ ERROR mismatched types
 }
diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr b/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr
index 4a2a619298c..6301ed45ac2 100644
--- a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr
+++ b/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/hrtb-exists-forall-fn.rs:22:34
+  --> $DIR/hrtb-exists-forall-fn.rs:17:34
    |
 LL |     let _: for<'b> fn(&'b u32) = foo(); //~ ERROR mismatched types
    |                                  ^^^^^ one type is more general than the other