diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/cycle-trait | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/cycle-trait')
6 files changed, 102 insertions, 0 deletions
diff --git a/tests/ui/cycle-trait/cycle-trait-default-type-trait.rs b/tests/ui/cycle-trait/cycle-trait-default-type-trait.rs new file mode 100644 index 000000000..6175b7df1 --- /dev/null +++ b/tests/ui/cycle-trait/cycle-trait-default-type-trait.rs @@ -0,0 +1,8 @@ +// Test a cycle where a type parameter on a trait has a default that +// again references the trait. + +trait Foo<X = Box<dyn Foo>> { + //~^ ERROR cycle detected +} + +fn main() { } diff --git a/tests/ui/cycle-trait/cycle-trait-default-type-trait.stderr b/tests/ui/cycle-trait/cycle-trait-default-type-trait.stderr new file mode 100644 index 000000000..9d715f494 --- /dev/null +++ b/tests/ui/cycle-trait/cycle-trait-default-type-trait.stderr @@ -0,0 +1,20 @@ +error[E0391]: cycle detected when computing type of `Foo::X` + --> $DIR/cycle-trait-default-type-trait.rs:4:23 + | +LL | trait Foo<X = Box<dyn Foo>> { + | ^^^ + | + = 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 + | +LL | / trait Foo<X = Box<dyn Foo>> { +LL | | +LL | | } +LL | | +LL | | fn main() { } + | |_____________^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.rs b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.rs new file mode 100644 index 000000000..e6ab2c790 --- /dev/null +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.rs @@ -0,0 +1,7 @@ +// Test a supertrait cycle where a trait extends itself. + +trait Chromosome: Chromosome { + //~^ ERROR cycle detected +} + +fn main() { } diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr new file mode 100644 index 000000000..f6ffcc4b5 --- /dev/null +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr @@ -0,0 +1,23 @@ +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`... + --> $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: cycle used when collecting item types in top-level module + --> $DIR/cycle-trait-supertrait-direct.rs:3:1 + | +LL | / trait Chromosome: Chromosome { +LL | | +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.rs b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.rs new file mode 100644 index 000000000..9a72b65da --- /dev/null +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.rs @@ -0,0 +1,13 @@ +// Test a supertrait cycle where the first trait we find (`A`) is not +// a direct participant in the cycle. + +trait A: B { +} + +trait B: C { + //~^ ERROR cycle detected +} + +trait C: B { } + +fn main() { } diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr new file mode 100644 index 000000000..0a2284e0e --- /dev/null +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr @@ -0,0 +1,31 @@ +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`... + --> $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`... + --> $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` + --> $DIR/cycle-trait-supertrait-indirect.rs:4:10 + | +LL | trait A: B { + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. |