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.
This commit is contained in:
bors 2020-12-03 02:00:46 +00:00
commit b4def89d76
28 changed files with 152 additions and 499 deletions

View file

@ -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() { }

View file

@ -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() {}

View file

@ -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`.

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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`.

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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() {}

View file

@ -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() {
}

View file

@ -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`.

View file

@ -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
|

View file

@ -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 {

View file

@ -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
|

View file

@ -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>

View file

@ -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> {

View file

@ -1,6 +1,5 @@
// check-pass
trait Expr: PartialEq<Self::Item> {
trait Expr : PartialEq<Self::Item> {
//~^ ERROR: cycle detected
type Item;
}

View file

@ -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`.