about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-12-03 02:00:46 +0000
committerbors <bors@rust-lang.org>2020-12-03 02:00:46 +0000
commitb4def89d76896eec73b4af33642ba7e5eb53c567 (patch)
tree2ab62ff68117de489e0701a2806bfa202eac44da /src
parent7dc1e852d43cb8c9e77dc1e53014f0eb85d2ebfb (diff)
parent37354ebc9794b0eb14b08c02177e3094c8fe91cd (diff)
Auto merge of #79637 - spastorino:revert-trait-inheritance-self, r=Mark-Simulacrum
Revert "Auto merge of #79209

r? `@nikomatsakis`

This has caused some issues (#79560) so better to revert and try to come up with a proper fix without rush.
Diffstat (limited to 'src')
-rw-r--r--src/test/incremental/cyclic-trait-hierarchy.rs10
-rw-r--r--src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs12
-rw-r--r--src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr16
-rw-r--r--src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs21
-rw-r--r--src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs10
-rw-r--r--src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs10
-rw-r--r--src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr16
-rw-r--r--src/test/ui/associated-type-bounds/super-trait-referencing-self.rs12
-rw-r--r--src/test/ui/associated-type-bounds/super-trait-referencing.rs19
-rw-r--r--src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs27
-rw-r--r--src/test/ui/cycle-projection-based-on-where-clause.rs24
-rw-r--r--src/test/ui/cycle-projection-based-on-where-clause.stderr16
-rw-r--r--src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr11
-rw-r--r--src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr18
-rw-r--r--src/test/ui/issues/issue-12511.stderr16
-rw-r--r--src/test/ui/issues/issue-20772.stderr6
-rw-r--r--src/test/ui/issues/issue-20825.stderr6
-rw-r--r--src/test/ui/issues/issue-22673.rs5
-rw-r--r--src/test/ui/issues/issue-22673.stderr16
19 files changed, 79 insertions, 192 deletions
diff --git a/src/test/incremental/cyclic-trait-hierarchy.rs b/src/test/incremental/cyclic-trait-hierarchy.rs
index b502e7207d5..03bb5eea765 100644
--- a/src/test/incremental/cyclic-trait-hierarchy.rs
+++ b/src/test/incremental/cyclic-trait-hierarchy.rs
@@ -3,11 +3,11 @@
 // revisions: rpass1 cfail2
 
 #[cfg(rpass1)]
-pub trait T2 {}
+pub trait T2 { }
 #[cfg(cfail2)]
-pub trait T2: T1 {}
-//[cfail2]~^ ERROR cycle detected when computing the super predicates of `T2`
+pub trait T2: T1 { }
+//[cfail2]~^ ERROR cycle detected when computing the supertraits of `T2`
 
-pub trait T1: T2 {}
+pub trait T1: T2 { }
 
-fn main() {}
+fn main() { }
diff --git a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs
deleted file mode 100644
index 1b6d6d0ff59..00000000000
--- a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// ignore-tidy-linelength
-
-trait Foo {
-    type Item;
-}
-trait Bar<T> {
-    type Item;
-}
-trait Baz: Foo + Bar<Self::Item> {}
-//~^ ERROR cycle detected when computing the super traits of `Baz` with associated type name `Item` [E0391]
-
-fn main() {}
diff --git a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
deleted file mode 100644
index bda1debeac0..00000000000
--- a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0391]: cycle detected when computing the super traits of `Baz` with associated type name `Item`
-  --> $DIR/ambiguous-associated-type2.rs:9:1
-   |
-LL | trait Baz: Foo + Bar<Self::Item> {}
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: ...which again requires computing the super traits of `Baz` with associated type name `Item`, completing the cycle
-note: cycle used when computing the super traits of `Baz`
-  --> $DIR/ambiguous-associated-type2.rs:9:1
-   |
-LL | trait Baz: Foo + Bar<Self::Item> {}
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs b/src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs
deleted file mode 100644
index 3eb50ab5547..00000000000
--- a/src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// check-pass
-
-trait Foo {
-    type Item;
-}
-
-trait Bar
-where
-    Self: Foo,
-{
-}
-
-#[allow(dead_code)]
-fn foo<M>(_m: M)
-where
-    M: Bar,
-    M::Item: Send,
-{
-}
-
-fn main() {}
diff --git a/src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs b/src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs
deleted file mode 100644
index b1e54ec0449..00000000000
--- a/src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// check-pass
-
-trait Foo<T> {}
-trait Bar {
-    type A;
-    type B;
-}
-trait Baz: Bar<B = u32> + Foo<Self::A> {}
-
-fn main() {}
diff --git a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs b/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs
deleted file mode 100644
index 07d0f8f8769..00000000000
--- a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#[allow(dead_code)]
-fn foo<M>(_m: M)
-where
-    M::Item: Temp,
-    //~^ ERROR cannot find trait `Temp` in this scope [E0405]
-    //~| ERROR associated type `Item` not found for `M` [E0220]
-{
-}
-
-fn main() {}
diff --git a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr b/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr
deleted file mode 100644
index bc2807b0396..00000000000
--- a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0405]: cannot find trait `Temp` in this scope
-  --> $DIR/missing-trait-bound-for-assoc-fails.rs:4:14
-   |
-LL |     M::Item: Temp,
-   |              ^^^^ not found in this scope
-
-error[E0220]: associated type `Item` not found for `M`
-  --> $DIR/missing-trait-bound-for-assoc-fails.rs:4:8
-   |
-LL |     M::Item: Temp,
-   |        ^^^^ associated type `Item` not found
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0220, E0405.
-For more information about an error, try `rustc --explain E0220`.
diff --git a/src/test/ui/associated-type-bounds/super-trait-referencing-self.rs b/src/test/ui/associated-type-bounds/super-trait-referencing-self.rs
deleted file mode 100644
index c82ec01f4d6..00000000000
--- a/src/test/ui/associated-type-bounds/super-trait-referencing-self.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// check-pass
-trait Foo {
-    type Bar;
-}
-trait Qux: Foo + AsRef<Self::Bar> {}
-trait Foo2 {}
-
-trait Qux2: Foo2 + AsRef<Self::Bar> {
-    type Bar;
-}
-
-fn main() {}
diff --git a/src/test/ui/associated-type-bounds/super-trait-referencing.rs b/src/test/ui/associated-type-bounds/super-trait-referencing.rs
deleted file mode 100644
index 2e97535157f..00000000000
--- a/src/test/ui/associated-type-bounds/super-trait-referencing.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// check-pass
-
-// The goal of this test is to ensure that T: Bar<T::Item>
-// in the where clause does not cycle
-
-trait Foo {
-    type Item;
-}
-
-trait Bar<T> {}
-
-fn baz<T>()
-where
-    T: Foo,
-    T: Bar<T::Item>,
-{
-}
-
-fn main() {}
diff --git a/src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs b/src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs
deleted file mode 100644
index 72a6be9ffc3..00000000000
--- a/src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-// check-pass
-
-// Test that we do not get a cycle due to
-// resolving `Self::Bar` in the where clauses
-// on a trait definition (in particular, in
-// a where clause that is defining a superpredicate).
-
-trait Foo {
-    type Bar;
-}
-trait Qux
-where
-    Self: Foo,
-    Self: AsRef<Self::Bar>,
-{
-}
-trait Foo2 {}
-
-trait Qux2
-where
-    Self: Foo2,
-    Self: AsRef<Self::Bar>,
-{
-    type Bar;
-}
-
-fn main() {}
diff --git a/src/test/ui/cycle-projection-based-on-where-clause.rs b/src/test/ui/cycle-projection-based-on-where-clause.rs
new file mode 100644
index 00000000000..d3609acfdff
--- /dev/null
+++ b/src/test/ui/cycle-projection-based-on-where-clause.rs
@@ -0,0 +1,24 @@
+// Example cycle where a bound on `T` uses a shorthand for `T`. This
+// creates a cycle because we have to know the bounds on `T` to figure
+// out what trait defines `Item`, but we can't know the bounds on `T`
+// without knowing how to handle `T::Item`.
+//
+// Note that in the future cases like this could perhaps become legal,
+// if we got more fine-grained about our cycle detection or changed
+// how we handle `T::Item` resolution.
+
+use std::ops::Add;
+
+// Preamble.
+trait Trait { type Item; }
+
+struct A<T>
+    where T : Trait,
+          T : Add<T::Item>
+    //~^ ERROR cycle detected
+{
+    data: T
+}
+
+fn main() {
+}
diff --git a/src/test/ui/cycle-projection-based-on-where-clause.stderr b/src/test/ui/cycle-projection-based-on-where-clause.stderr
new file mode 100644
index 00000000000..2c337cc6bf9
--- /dev/null
+++ b/src/test/ui/cycle-projection-based-on-where-clause.stderr
@@ -0,0 +1,16 @@
+error[E0391]: cycle detected when computing the bounds for type parameter `T`
+  --> $DIR/cycle-projection-based-on-where-clause.rs:17:19
+   |
+LL |           T : Add<T::Item>
+   |                   ^^^^^^^
+   |
+   = note: ...which again requires computing the bounds for type parameter `T`, completing the cycle
+note: cycle used when computing explicit predicates of `A`
+  --> $DIR/cycle-projection-based-on-where-clause.rs:17:19
+   |
+LL |           T : Add<T::Item>
+   |                   ^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr
index ee54b2fd151..8aa3ac8abf5 100644
--- a/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr
+++ b/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr
@@ -1,15 +1,10 @@
-error[E0391]: cycle detected when computing the super predicates of `Chromosome`
-  --> $DIR/cycle-trait-supertrait-direct.rs:3:1
-   |
-LL | trait Chromosome: Chromosome {
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-note: ...which requires computing the super traits of `Chromosome`...
+error[E0391]: cycle detected when computing the supertraits of `Chromosome`
   --> $DIR/cycle-trait-supertrait-direct.rs:3:19
    |
 LL | trait Chromosome: Chromosome {
    |                   ^^^^^^^^^^
-   = note: ...which again requires computing the super predicates of `Chromosome`, completing the cycle
+   |
+   = note: ...which again requires computing the supertraits of `Chromosome`, completing the cycle
 note: cycle used when collecting item types in top-level module
   --> $DIR/cycle-trait-supertrait-direct.rs:3:1
    |
diff --git a/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr b/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr
index 0a2284e0efb..9740f43a4ba 100644
--- a/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr
+++ b/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr
@@ -1,26 +1,16 @@
-error[E0391]: cycle detected when computing the super predicates of `B`
-  --> $DIR/cycle-trait-supertrait-indirect.rs:7:1
-   |
-LL | trait B: C {
-   | ^^^^^^^^^^
-   |
-note: ...which requires computing the super traits of `B`...
+error[E0391]: cycle detected when computing the supertraits of `B`
   --> $DIR/cycle-trait-supertrait-indirect.rs:7:10
    |
 LL | trait B: C {
    |          ^
-note: ...which requires computing the super predicates of `C`...
-  --> $DIR/cycle-trait-supertrait-indirect.rs:11:1
    |
-LL | trait C: B { }
-   | ^^^^^^^^^^
-note: ...which requires computing the super traits of `C`...
+note: ...which requires computing the supertraits of `C`...
   --> $DIR/cycle-trait-supertrait-indirect.rs:11:10
    |
 LL | trait C: B { }
    |          ^
-   = note: ...which again requires computing the super predicates of `B`, completing the cycle
-note: cycle used when computing the super traits of `A`
+   = note: ...which again requires computing the supertraits of `B`, completing the cycle
+note: cycle used when computing the supertraits of `A`
   --> $DIR/cycle-trait-supertrait-indirect.rs:4:10
    |
 LL | trait A: B {
diff --git a/src/test/ui/issues/issue-12511.stderr b/src/test/ui/issues/issue-12511.stderr
index 5f2b98c5237..37e38ff60ae 100644
--- a/src/test/ui/issues/issue-12511.stderr
+++ b/src/test/ui/issues/issue-12511.stderr
@@ -1,25 +1,15 @@
-error[E0391]: cycle detected when computing the super predicates of `T1`
-  --> $DIR/issue-12511.rs:1:1
-   |
-LL | trait T1 : T2 {
-   | ^^^^^^^^^^^^^
-   |
-note: ...which requires computing the super traits of `T1`...
+error[E0391]: cycle detected when computing the supertraits of `T1`
   --> $DIR/issue-12511.rs:1:12
    |
 LL | trait T1 : T2 {
    |            ^^
-note: ...which requires computing the super predicates of `T2`...
-  --> $DIR/issue-12511.rs:5:1
    |
-LL | trait T2 : T1 {
-   | ^^^^^^^^^^^^^
-note: ...which requires computing the super traits of `T2`...
+note: ...which requires computing the supertraits of `T2`...
   --> $DIR/issue-12511.rs:5:12
    |
 LL | trait T2 : T1 {
    |            ^^
-   = note: ...which again requires computing the super predicates of `T1`, completing the cycle
+   = note: ...which again requires computing the supertraits of `T1`, completing the cycle
 note: cycle used when collecting item types in top-level module
   --> $DIR/issue-12511.rs:1:1
    |
diff --git a/src/test/ui/issues/issue-20772.stderr b/src/test/ui/issues/issue-20772.stderr
index 4aecc7eab46..d64636310a3 100644
--- a/src/test/ui/issues/issue-20772.stderr
+++ b/src/test/ui/issues/issue-20772.stderr
@@ -1,4 +1,4 @@
-error[E0391]: cycle detected when computing the super traits of `T` with associated type name `Item`
+error[E0391]: cycle detected when computing the supertraits of `T`
   --> $DIR/issue-20772.rs:1:1
    |
 LL | / trait T : Iterator<Item=Self::Item>
@@ -6,8 +6,8 @@ LL | |
 LL | | {}
    | |__^
    |
-   = note: ...which again requires computing the super traits of `T` with associated type name `Item`, completing the cycle
-note: cycle used when computing the super traits of `T`
+   = note: ...which again requires computing the supertraits of `T`, completing the cycle
+note: cycle used when collecting item types in top-level module
   --> $DIR/issue-20772.rs:1:1
    |
 LL | / trait T : Iterator<Item=Self::Item>
diff --git a/src/test/ui/issues/issue-20825.stderr b/src/test/ui/issues/issue-20825.stderr
index ccbe06d9c0d..5f9709d1c64 100644
--- a/src/test/ui/issues/issue-20825.stderr
+++ b/src/test/ui/issues/issue-20825.stderr
@@ -1,11 +1,11 @@
-error[E0391]: cycle detected when computing the super traits of `Processor` with associated type name `Input`
+error[E0391]: cycle detected when computing the supertraits of `Processor`
   --> $DIR/issue-20825.rs:5:1
    |
 LL | pub trait Processor: Subscriber<Input = Self::Input> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: ...which again requires computing the super traits of `Processor` with associated type name `Input`, completing the cycle
-note: cycle used when computing the super traits of `Processor`
+   = note: ...which again requires computing the supertraits of `Processor`, completing the cycle
+note: cycle used when collecting item types in top-level module
   --> $DIR/issue-20825.rs:5:1
    |
 LL | pub trait Processor: Subscriber<Input = Self::Input> {
diff --git a/src/test/ui/issues/issue-22673.rs b/src/test/ui/issues/issue-22673.rs
index 4b9b4d6b23d..ba8057b684d 100644
--- a/src/test/ui/issues/issue-22673.rs
+++ b/src/test/ui/issues/issue-22673.rs
@@ -1,6 +1,5 @@
-// check-pass
-
-trait Expr: PartialEq<Self::Item> {
+trait Expr : PartialEq<Self::Item> {
+    //~^ ERROR: cycle detected
     type Item;
 }
 
diff --git a/src/test/ui/issues/issue-22673.stderr b/src/test/ui/issues/issue-22673.stderr
new file mode 100644
index 00000000000..9e7e4b218b1
--- /dev/null
+++ b/src/test/ui/issues/issue-22673.stderr
@@ -0,0 +1,16 @@
+error[E0391]: cycle detected when computing the supertraits of `Expr`
+  --> $DIR/issue-22673.rs:1:1
+   |
+LL | trait Expr : PartialEq<Self::Item> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: ...which again requires computing the supertraits of `Expr`, completing the cycle
+note: cycle used when collecting item types in top-level module
+  --> $DIR/issue-22673.rs:1:1
+   |
+LL | trait Expr : PartialEq<Self::Item> {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.