about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-04-27 15:17:45 +0200
committerMatthias Krüger <matthias.krueger@famsik.de>2024-04-28 10:23:11 +0200
commitf536a06a5aaf99b0c25de577ad102cdd1c0e59f9 (patch)
tree7e293f0be0e5c2e755bfb836355330366b77573a
parent27338f2fe01c4632aa32ba29f8f5c801afe26471 (diff)
add test for ice expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr
Fixes https://github.com/rust-lang/rust/issues/113776
-rw-r--r--tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs23
-rw-r--r--tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr68
2 files changed, 91 insertions, 0 deletions
diff --git a/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs b/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs
new file mode 100644
index 00000000000..4bea3ad87f5
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs
@@ -0,0 +1,23 @@
+// issue: rust-lang/rust#113776
+// ice: expected type of closure body to be a closure or coroutine
+//@ edition: 2021
+#![allow(incomplete_features)]
+#![feature(generic_const_exprs)]
+
+use core::ops::SubAssign;
+
+fn f<T>(
+    data: &[(); {
+         let f: F = async { 1 };
+         //~^ ERROR cannot find type `F` in this scope
+
+         1
+     }],
+) -> impl Iterator<Item = SubAssign> {
+//~^ ERROR the type parameter `Rhs` must be explicitly specified
+//~| ERROR `()` is not an iterator
+//~| ERROR trait objects must include the `dyn` keyword
+//~| ERROR the type parameter `Rhs` must be explicitly specified [E0393]
+}
+
+pub fn main() {}
diff --git a/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr b/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr
new file mode 100644
index 00000000000..be79450a3ce
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr
@@ -0,0 +1,68 @@
+error[E0412]: cannot find type `F` in this scope
+  --> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:11:17
+   |
+LL |          let f: F = async { 1 };
+   |                 ^
+  --> $SRC_DIR/core/src/ops/function.rs:LL:COL
+   |
+   = note: similarly named trait `Fn` defined here
+   |
+help: a trait with a similar name exists
+   |
+LL |          let f: Fn = async { 1 };
+   |                 ~~
+help: you might be missing a type parameter
+   |
+LL | fn f<T, F>(
+   |       +++
+
+error[E0393]: the type parameter `Rhs` must be explicitly specified
+  --> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:27
+   |
+LL | ) -> impl Iterator<Item = SubAssign> {
+   |                           ^^^^^^^^^ help: set the type parameter to the desired type: `SubAssign<Rhs>`
+  --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
+   |
+   = note: type parameter `Rhs` must be specified for this
+   |
+   = note: because of the default `Self` reference, type parameters must be specified on object types
+
+error[E0393]: the type parameter `Rhs` must be explicitly specified
+  --> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:27
+   |
+LL | ) -> impl Iterator<Item = SubAssign> {
+   |                           ^^^^^^^^^ help: set the type parameter to the desired type: `SubAssign<Rhs>`
+  --> $SRC_DIR/core/src/ops/arith.rs:LL:COL
+   |
+   = note: type parameter `Rhs` must be specified for this
+   |
+   = note: because of the default `Self` reference, type parameters must be specified on object types
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error[E0277]: `()` is not an iterator
+  --> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:6
+   |
+LL | ) -> impl Iterator<Item = SubAssign> {
+   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
+   |
+   = help: the trait `Iterator` is not implemented for `()`
+
+error[E0782]: trait objects must include the `dyn` keyword
+  --> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:27
+   |
+LL | ) -> impl Iterator<Item = SubAssign> {
+   |                           ^^^^^^^^^
+   |
+help: add `dyn` keyword before this trait
+   |
+LL | ) -> impl Iterator<Item = dyn SubAssign> {
+   |                           +++
+help: you might have meant to write a bound here
+   |
+LL | ) -> impl Iterator<Item: SubAssign> {
+   |                        ~
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0277, E0393, E0412, E0782.
+For more information about an error, try `rustc --explain E0277`.