From 6278e0f50745bafb8563c5765ef6a1622e3718c4 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 18 Aug 2024 16:35:03 +0000 Subject: [PATCH] Promote crash tests to ui. --- tests/crashes/119716-2.rs | 4 --- tests/crashes/119716.rs | 4 --- tests/crashes/121422.rs | 8 ----- tests/crashes/125843.rs | 4 --- tests/crashes/129099.rs | 15 ---------- .../bound-lifetime-through-dyn-trait.rs | 18 +++++++++++ .../bound-lifetime-through-dyn-trait.stderr | 28 +++++++++++++++++ .../non-lifetime-binder-in-constraint.rs | 13 ++++++++ .../non-lifetime-binder-in-constraint.stderr | 30 +++++++++++++++++++ .../non-lifetime-binder.rs | 10 +++++++ .../non-lifetime-binder.stderr | 25 ++++++++++++++++ 11 files changed, 124 insertions(+), 35 deletions(-) delete mode 100644 tests/crashes/119716-2.rs delete mode 100644 tests/crashes/119716.rs delete mode 100644 tests/crashes/121422.rs delete mode 100644 tests/crashes/125843.rs delete mode 100644 tests/crashes/129099.rs create mode 100644 tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.rs create mode 100644 tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr create mode 100644 tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.rs create mode 100644 tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.stderr create mode 100644 tests/ui/type-alias-impl-trait/non-lifetime-binder.rs create mode 100644 tests/ui/type-alias-impl-trait/non-lifetime-binder.stderr diff --git a/tests/crashes/119716-2.rs b/tests/crashes/119716-2.rs deleted file mode 100644 index 47bffb5c1de..00000000000 --- a/tests/crashes/119716-2.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ known-bug: #119716 -#![feature(non_lifetime_binders)] -trait Trait {} -fn f() -> impl for Trait> {} diff --git a/tests/crashes/119716.rs b/tests/crashes/119716.rs deleted file mode 100644 index d7cba0f51c4..00000000000 --- a/tests/crashes/119716.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ known-bug: #119716 -#![feature(non_lifetime_binders)] -trait v0 {} -fn kind :(v3main impl for v0<'_, v2 = impl v0 + '_>) {} diff --git a/tests/crashes/121422.rs b/tests/crashes/121422.rs deleted file mode 100644 index 5d7ef6e8ce9..00000000000 --- a/tests/crashes/121422.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #121422 -#![feature(non_lifetime_binders)] - -trait Trait {} - -fn produce() -> impl for Trait<(), Assoc = impl Trait> { - 16 -} diff --git a/tests/crashes/125843.rs b/tests/crashes/125843.rs deleted file mode 100644 index 8b9a3913c7e..00000000000 --- a/tests/crashes/125843.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ known-bug: rust-lang/rust#125843 -#![feature(non_lifetime_binders)] -trait v0<> {} -fn kind :(v3main impl for v0<'_, v2 = impl v0 + '_>) {} diff --git a/tests/crashes/129099.rs b/tests/crashes/129099.rs deleted file mode 100644 index 9aaab756b5b..00000000000 --- a/tests/crashes/129099.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ known-bug: rust-lang/rust#129099 - -#![feature(type_alias_impl_trait)] - -fn dyn_hoops() -> dyn for<'a> Iterator> { - loop {} -} - -pub fn main() { - type Opaque = impl Sized; - fn define() -> Opaque { - let x: Opaque = dyn_hoops::<()>(0); - x - } -} diff --git a/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.rs b/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.rs new file mode 100644 index 00000000000..df589473a84 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.rs @@ -0,0 +1,18 @@ +#![feature(type_alias_impl_trait)] + +trait Captures<'a> {} +impl Captures<'_> for T {} + +fn dyn_hoops() -> dyn for<'a> Iterator> { + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type + loop {} +} + +pub fn main() { + //~^ ERROR item does not constrain `Opaque::{opaque#0}`, but has it in its signature + type Opaque = impl Sized; + fn define() -> Opaque { + let x: Opaque = dyn_hoops::<()>(); + x + } +} diff --git a/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr b/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr new file mode 100644 index 00000000000..59d9ff86c6e --- /dev/null +++ b/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr @@ -0,0 +1,28 @@ +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type + --> $DIR/bound-lifetime-through-dyn-trait.rs:6:71 + | +LL | fn dyn_hoops() -> dyn for<'a> Iterator> { + | ^^ + | +note: lifetime declared here + --> $DIR/bound-lifetime-through-dyn-trait.rs:6:37 + | +LL | fn dyn_hoops() -> dyn for<'a> Iterator> { + | ^^ + +error: item does not constrain `Opaque::{opaque#0}`, but has it in its signature + --> $DIR/bound-lifetime-through-dyn-trait.rs:11:8 + | +LL | pub fn main() { + | ^^^^ + | + = note: consider moving the opaque type's declaration and defining uses into a separate module +note: this opaque type is in the signature + --> $DIR/bound-lifetime-through-dyn-trait.rs:13:19 + | +LL | type Opaque = impl Sized; + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.rs b/tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.rs new file mode 100644 index 00000000000..dda42580e0f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.rs @@ -0,0 +1,13 @@ +#![allow(incomplete_features)] +#![feature(non_lifetime_binders)] + +trait Trait {} + +fn produce() -> impl for Trait<(), Assoc = impl Trait> { + //~^ ERROR associated type `Assoc` not found for `Trait` + //~| ERROR associated type `Assoc` not found for `Trait` + //~| the trait bound `{integer}: Trait<()>` is not satisfied + 16 +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.stderr b/tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.stderr new file mode 100644 index 00000000000..fa3306ff11f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/non-lifetime-binder-in-constraint.stderr @@ -0,0 +1,30 @@ +error[E0220]: associated type `Assoc` not found for `Trait` + --> $DIR/non-lifetime-binder-in-constraint.rs:6:39 + | +LL | fn produce() -> impl for Trait<(), Assoc = impl Trait> { + | ^^^^^ associated type `Assoc` not found + +error[E0220]: associated type `Assoc` not found for `Trait` + --> $DIR/non-lifetime-binder-in-constraint.rs:6:39 + | +LL | fn produce() -> impl for Trait<(), Assoc = impl Trait> { + | ^^^^^ associated type `Assoc` not found + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0277]: the trait bound `{integer}: Trait<()>` is not satisfied + --> $DIR/non-lifetime-binder-in-constraint.rs:6:17 + | +LL | fn produce() -> impl for Trait<(), Assoc = impl Trait> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<()>` is not implemented for `{integer}` + | +help: this trait has no implementations, consider adding one + --> $DIR/non-lifetime-binder-in-constraint.rs:4:1 + | +LL | trait Trait {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0220, E0277. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/type-alias-impl-trait/non-lifetime-binder.rs b/tests/ui/type-alias-impl-trait/non-lifetime-binder.rs new file mode 100644 index 00000000000..23951c34270 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/non-lifetime-binder.rs @@ -0,0 +1,10 @@ +#![allow(incomplete_features)] +#![feature(non_lifetime_binders)] + +trait Trait {} + +fn f() -> impl for Trait> {} +//~^ ERROR nested `impl Trait` is not allowed +//~| ERROR the trait bound `(): Trait>` is not satisfied + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/non-lifetime-binder.stderr b/tests/ui/type-alias-impl-trait/non-lifetime-binder.stderr new file mode 100644 index 00000000000..5859d952b75 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/non-lifetime-binder.stderr @@ -0,0 +1,25 @@ +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/non-lifetime-binder.rs:6:29 + | +LL | fn f() -> impl for Trait> {} + | ------------------^^^^^^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error[E0277]: the trait bound `(): Trait>` is not satisfied + --> $DIR/non-lifetime-binder.rs:6:11 + | +LL | fn f() -> impl for Trait> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait>` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/non-lifetime-binder.rs:4:1 + | +LL | trait Trait {} + | ^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0666. +For more information about an error, try `rustc --explain E0277`.