about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-01 03:43:37 +0000
committerbors <bors@rust-lang.org>2021-09-01 03:43:37 +0000
commitc4f26b15e37101c54829efab456922a53e3103ad (patch)
treece7caaa6f4446a1faa1414554ef0f1715847a4f9 /src/test/ui
parentc2a408840ad18f74280805535f0b7193528ff3df (diff)
parentd96234bed72e1935d8ab9a0c7a7e70027c86ad77 (diff)
downloadrust-c4f26b15e37101c54829efab456922a53e3103ad.tar.gz
rust-c4f26b15e37101c54829efab456922a53e3103ad.zip
Auto merge of #88121 - camelid:better-recursive-alias-error, r=estebank
Improve errors for recursive type aliases

Fixes #17539.
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr2
-rw-r--r--src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr2
-rw-r--r--src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr4
-rw-r--r--src/test/ui/infinite/infinite-struct.stderr2
-rw-r--r--src/test/ui/infinite/infinite-tag-type-recursion.stderr2
-rw-r--r--src/test/ui/infinite/infinite-trait-alias-recursion.rs10
-rw-r--r--src/test/ui/infinite/infinite-trait-alias-recursion.stderr42
-rw-r--r--src/test/ui/infinite/infinite-type-alias-mutual-recursion.rs6
-rw-r--r--src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr34
-rw-r--r--src/test/ui/infinite/infinite-vec-type-recursion.stderr7
-rw-r--r--src/test/ui/issues/issue-20772.stderr2
-rw-r--r--src/test/ui/issues/issue-20825.stderr2
-rw-r--r--src/test/ui/issues/issue-21177.stderr2
-rw-r--r--src/test/ui/issues/issue-34373.stderr2
-rw-r--r--src/test/ui/resolve/issue-23305.stderr2
-rw-r--r--src/test/ui/resolve/resolve-self-in-impl.stderr10
16 files changed, 113 insertions, 18 deletions
diff --git a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
index e72ef0e4b33..4162cdaa8dc 100644
--- a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
+++ b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
@@ -4,7 +4,7 @@ error[E0391]: cycle detected when computing the super traits of `Baz` with assoc
 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: ...which immediately requires computing the super traits of `Baz` with associated type name `Item` again
 note: cycle used when computing the super traits of `Baz`
   --> $DIR/ambiguous-associated-type2.rs:7:1
    |
diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr
index f3edf1c350f..97f3c759355 100644
--- a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr
+++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr
@@ -14,7 +14,7 @@ error[E0391]: cycle detected when building specialization graph of trait `Trait`
 LL | trait Trait<T> { type Assoc; }
    | ^^^^^^^^^^^^^^
    |
-   = note: ...which again requires building specialization graph of trait `Trait`, completing the cycle
+   = note: ...which immediately requires building specialization graph of trait `Trait` again
 note: cycle used when coherence checking all impls of trait `Trait`
   --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:9:1
    |
diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr
index 58c458709a8..fc842fada5a 100644
--- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr
+++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr
@@ -4,7 +4,7 @@ error[E0391]: cycle detected when computing type of `Foo::X`
 LL | trait Foo<X = Box<dyn Foo>> {
    |                       ^^^
    |
-   = note: ...which again requires computing type of `Foo::X`, completing the cycle
+   = note: ...which immediately requires computing type of `Foo::X` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/cycle-trait-default-type-trait.rs:4:1
    |
@@ -17,7 +17,7 @@ error[E0391]: cycle detected when computing type of `Foo::X`
 LL | trait Foo<X = Box<dyn Foo>> {
    |                       ^^^
    |
-   = note: ...which again requires computing type of `Foo::X`, completing the cycle
+   = note: ...which immediately requires computing type of `Foo::X` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/cycle-trait-default-type-trait.rs:4:1
    |
diff --git a/src/test/ui/infinite/infinite-struct.stderr b/src/test/ui/infinite/infinite-struct.stderr
index 7ffb51061b7..369645f9030 100644
--- a/src/test/ui/infinite/infinite-struct.stderr
+++ b/src/test/ui/infinite/infinite-struct.stderr
@@ -18,7 +18,7 @@ error[E0391]: cycle detected when computing drop-check constraints for `Take`
 LL | struct Take(Take);
    | ^^^^^^^^^^^^^^^^^^
    |
-   = note: ...which again requires computing drop-check constraints for `Take`, completing the cycle
+   = note: ...which immediately requires computing drop-check constraints for `Take` again
    = note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: Take } }`
 
 error: aborting due to 2 previous errors
diff --git a/src/test/ui/infinite/infinite-tag-type-recursion.stderr b/src/test/ui/infinite/infinite-tag-type-recursion.stderr
index 1f147e070b4..61b5e946775 100644
--- a/src/test/ui/infinite/infinite-tag-type-recursion.stderr
+++ b/src/test/ui/infinite/infinite-tag-type-recursion.stderr
@@ -17,7 +17,7 @@ error[E0391]: cycle detected when computing drop-check constraints for `MList`
 LL | enum MList { Cons(isize, MList), Nil }
    | ^^^^^^^^^^
    |
-   = note: ...which again requires computing drop-check constraints for `MList`, completing the cycle
+   = note: ...which immediately requires computing drop-check constraints for `MList` again
    = note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: MList } }`
 
 error: aborting due to 2 previous errors
diff --git a/src/test/ui/infinite/infinite-trait-alias-recursion.rs b/src/test/ui/infinite/infinite-trait-alias-recursion.rs
new file mode 100644
index 00000000000..ec86744e68c
--- /dev/null
+++ b/src/test/ui/infinite/infinite-trait-alias-recursion.rs
@@ -0,0 +1,10 @@
+#![feature(trait_alias)]
+
+trait T1 = T2;
+//~^ ERROR cycle detected when computing the super predicates of `T1`
+
+trait T2 = T3;
+
+trait T3 = T1 + T3;
+
+fn main() {}
diff --git a/src/test/ui/infinite/infinite-trait-alias-recursion.stderr b/src/test/ui/infinite/infinite-trait-alias-recursion.stderr
new file mode 100644
index 00000000000..5ecaedb3cb2
--- /dev/null
+++ b/src/test/ui/infinite/infinite-trait-alias-recursion.stderr
@@ -0,0 +1,42 @@
+error[E0391]: cycle detected when computing the super predicates of `T1`
+  --> $DIR/infinite-trait-alias-recursion.rs:3:1
+   |
+LL | trait T1 = T2;
+   | ^^^^^^^^^^^^^^
+   |
+note: ...which requires computing the super traits of `T1`...
+  --> $DIR/infinite-trait-alias-recursion.rs:3:12
+   |
+LL | trait T1 = T2;
+   |            ^^
+note: ...which requires computing the super predicates of `T2`...
+  --> $DIR/infinite-trait-alias-recursion.rs:6:1
+   |
+LL | trait T2 = T3;
+   | ^^^^^^^^^^^^^^
+note: ...which requires computing the super traits of `T2`...
+  --> $DIR/infinite-trait-alias-recursion.rs:6:12
+   |
+LL | trait T2 = T3;
+   |            ^^
+note: ...which requires computing the super predicates of `T3`...
+  --> $DIR/infinite-trait-alias-recursion.rs:8:1
+   |
+LL | trait T3 = T1 + T3;
+   | ^^^^^^^^^^^^^^^^^^^
+note: ...which requires computing the super traits of `T3`...
+  --> $DIR/infinite-trait-alias-recursion.rs:8:12
+   |
+LL | trait T3 = T1 + T3;
+   |            ^^
+   = note: ...which again requires computing the super predicates of `T1`, completing the cycle
+   = note: trait aliases cannot be recursive
+note: cycle used when collecting item types in top-level module
+  --> $DIR/infinite-trait-alias-recursion.rs:3:1
+   |
+LL | trait T1 = T2;
+   | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/infinite/infinite-type-alias-mutual-recursion.rs b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.rs
new file mode 100644
index 00000000000..5381eedcfac
--- /dev/null
+++ b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.rs
@@ -0,0 +1,6 @@
+type X1 = X2;
+//~^ ERROR cycle detected when expanding type alias `X1`
+type X2 = X3;
+type X3 = X1;
+
+fn main() {}
diff --git a/src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr
new file mode 100644
index 00000000000..7f82b294434
--- /dev/null
+++ b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr
@@ -0,0 +1,34 @@
+error[E0391]: cycle detected when expanding type alias `X1`
+  --> $DIR/infinite-type-alias-mutual-recursion.rs:1:11
+   |
+LL | type X1 = X2;
+   |           ^^
+   |
+note: ...which requires expanding type alias `X2`...
+  --> $DIR/infinite-type-alias-mutual-recursion.rs:3:11
+   |
+LL | type X2 = X3;
+   |           ^^
+note: ...which requires expanding type alias `X3`...
+  --> $DIR/infinite-type-alias-mutual-recursion.rs:4:11
+   |
+LL | type X3 = X1;
+   |           ^^
+   = note: ...which again requires expanding type alias `X1`, completing the cycle
+   = note: type aliases cannot be recursive
+   = help: consider using a struct, enum, or union instead to break the cycle
+   = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
+note: cycle used when collecting item types in top-level module
+  --> $DIR/infinite-type-alias-mutual-recursion.rs:1:1
+   |
+LL | / type X1 = X2;
+LL | |
+LL | | type X2 = X3;
+LL | | type X3 = X1;
+LL | |
+LL | | fn main() {}
+   | |____________^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/infinite/infinite-vec-type-recursion.stderr b/src/test/ui/infinite/infinite-vec-type-recursion.stderr
index 77adefeb124..1e487a5b11c 100644
--- a/src/test/ui/infinite/infinite-vec-type-recursion.stderr
+++ b/src/test/ui/infinite/infinite-vec-type-recursion.stderr
@@ -1,10 +1,13 @@
-error[E0391]: cycle detected when computing type of `X`
+error[E0391]: cycle detected when expanding type alias `X`
   --> $DIR/infinite-vec-type-recursion.rs:1:14
    |
 LL | type X = Vec<X>;
    |              ^
    |
-   = note: ...which again requires computing type of `X`, completing the cycle
+   = note: ...which immediately requires expanding type alias `X` again
+   = note: type aliases cannot be recursive
+   = help: consider using a struct, enum, or union instead to break the cycle
+   = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
 note: cycle used when collecting item types in top-level module
   --> $DIR/infinite-vec-type-recursion.rs:1:1
    |
diff --git a/src/test/ui/issues/issue-20772.stderr b/src/test/ui/issues/issue-20772.stderr
index 4aecc7eab46..c964dc41dce 100644
--- a/src/test/ui/issues/issue-20772.stderr
+++ b/src/test/ui/issues/issue-20772.stderr
@@ -6,7 +6,7 @@ LL | |
 LL | | {}
    | |__^
    |
-   = note: ...which again requires computing the super traits of `T` with associated type name `Item`, completing the cycle
+   = note: ...which immediately requires computing the super traits of `T` with associated type name `Item` again
 note: cycle used when computing the super traits of `T`
   --> $DIR/issue-20772.rs:1:1
    |
diff --git a/src/test/ui/issues/issue-20825.stderr b/src/test/ui/issues/issue-20825.stderr
index ccbe06d9c0d..be2bbd44800 100644
--- a/src/test/ui/issues/issue-20825.stderr
+++ b/src/test/ui/issues/issue-20825.stderr
@@ -4,7 +4,7 @@ error[E0391]: cycle detected when computing the super traits of `Processor` with
 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: ...which immediately requires computing the super traits of `Processor` with associated type name `Input` again
 note: cycle used when computing the super traits of `Processor`
   --> $DIR/issue-20825.rs:5:1
    |
diff --git a/src/test/ui/issues/issue-21177.stderr b/src/test/ui/issues/issue-21177.stderr
index 59cc6550a8b..6877a184605 100644
--- a/src/test/ui/issues/issue-21177.stderr
+++ b/src/test/ui/issues/issue-21177.stderr
@@ -4,7 +4,7 @@ error[E0391]: cycle detected when computing the bounds for type parameter `T`
 LL | fn foo<T: Trait<A = T::B>>() { }
    |                     ^^^^
    |
-   = note: ...which again requires computing the bounds for type parameter `T`, completing the cycle
+   = note: ...which immediately requires computing the bounds for type parameter `T` again
 note: cycle used when computing explicit predicates of `foo`
   --> $DIR/issue-21177.rs:6:21
    |
diff --git a/src/test/ui/issues/issue-34373.stderr b/src/test/ui/issues/issue-34373.stderr
index e8c1e8f9669..8be3cfa72fb 100644
--- a/src/test/ui/issues/issue-34373.stderr
+++ b/src/test/ui/issues/issue-34373.stderr
@@ -4,7 +4,7 @@ error[E0391]: cycle detected when computing type of `Foo::T`
 LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
    |                              ^^^^^^^^^^
    |
-note: ...which requires computing type of `DefaultFoo`...
+note: ...which requires expanding type alias `DefaultFoo`...
   --> $DIR/issue-34373.rs:8:19
    |
 LL | type DefaultFoo = Foo;
diff --git a/src/test/ui/resolve/issue-23305.stderr b/src/test/ui/resolve/issue-23305.stderr
index 525b5cf7d84..0dcf0184db1 100644
--- a/src/test/ui/resolve/issue-23305.stderr
+++ b/src/test/ui/resolve/issue-23305.stderr
@@ -4,7 +4,7 @@ error[E0391]: cycle detected when computing type of `<impl at $DIR/issue-23305.r
 LL | impl dyn ToNbt<Self> {}
    |                ^^^^
    |
-   = note: ...which again requires computing type of `<impl at $DIR/issue-23305.rs:5:1: 5:24>`, completing the cycle
+   = note: ...which immediately requires computing type of `<impl at $DIR/issue-23305.rs:5:1: 5:24>` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/issue-23305.rs:1:1
    |
diff --git a/src/test/ui/resolve/resolve-self-in-impl.stderr b/src/test/ui/resolve/resolve-self-in-impl.stderr
index 5b5c1834cad..7f623e47353 100644
--- a/src/test/ui/resolve/resolve-self-in-impl.stderr
+++ b/src/test/ui/resolve/resolve-self-in-impl.stderr
@@ -4,7 +4,7 @@ error[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-
 LL | impl Tr for Self {}
    |             ^^^^
    |
-   = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:14:1: 14:20>`, completing the cycle
+   = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:14:1: 14:20>` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/resolve-self-in-impl.rs:1:1
    |
@@ -23,7 +23,7 @@ error[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-
 LL | impl Tr for S<Self> {}
    |               ^^^^
    |
-   = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:15:1: 15:23>`, completing the cycle
+   = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:15:1: 15:23>` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/resolve-self-in-impl.rs:1:1
    |
@@ -42,7 +42,7 @@ error[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-
 LL | impl Self {}
    |      ^^^^
    |
-   = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:16:1: 16:13>`, completing the cycle
+   = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:16:1: 16:13>` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/resolve-self-in-impl.rs:1:1
    |
@@ -61,7 +61,7 @@ error[E0391]: cycle detected when computing type of `<impl at $DIR/resolve-self-
 LL | impl S<Self> {}
    |        ^^^^
    |
-   = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:17:1: 17:16>`, completing the cycle
+   = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:17:1: 17:16>` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/resolve-self-in-impl.rs:1:1
    |
@@ -80,7 +80,7 @@ error[E0391]: cycle detected when computing trait implemented by `<impl at $DIR/
 LL | impl Tr<Self::A> for S {}
    | ^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: ...which again requires computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:18:1: 18:26>`, completing the cycle
+   = note: ...which immediately requires computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:18:1: 18:26>` again
 note: cycle used when collecting item types in top-level module
   --> $DIR/resolve-self-in-impl.rs:1:1
    |