about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-08-24 14:45:03 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-08-31 00:14:23 -0700
commit5384d5584f6fd596df3a86e2cd4e0281b27d10db (patch)
treee1cdd6075003de703683c8afa69cb5454cd9371a /src/test
parent444bc3ca6607f7bdeb088b34db23c01e056900b1 (diff)
downloadrust-5384d5584f6fd596df3a86e2cd4e0281b27d10db.tar.gz
rust-5384d5584f6fd596df3a86e2cd4e0281b27d10db.zip
Suggest call fn ctor passed as arg to fn with type param bounds
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs10
-rw-r--r--src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr14
-rw-r--r--src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs18
-rw-r--r--src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr14
4 files changed, 56 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs
new file mode 100644
index 00000000000..a2d2ba145bc
--- /dev/null
+++ b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs
@@ -0,0 +1,10 @@
+// edition:2018
+use std::future::Future;
+
+async fn foo() {}
+
+fn bar(f: impl Future<Output=()>) {}
+
+fn main() {
+    bar(foo); //~ERROR E0277
+}
diff --git a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
new file mode 100644
index 00000000000..5735f725dc3
--- /dev/null
+++ b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `fn() -> impl std::future::Future {foo}: std::future::Future` is not satisfied
+  --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:9:5
+   |
+LL | fn bar(f: impl Future<Output=()>) {}
+   | --------------------------------- required by `bar`
+...
+LL |     bar(foo);
+   |     ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
+   |
+   = help: it looks like you forgot to use parentheses to call the function: `foo()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs
new file mode 100644
index 00000000000..acd149c5854
--- /dev/null
+++ b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs
@@ -0,0 +1,18 @@
+// edition:2018
+trait T {
+    type O;
+}
+
+struct S;
+
+impl T for S {
+    type O = ();
+}
+
+fn foo() -> impl T<O=()> { S }
+
+fn bar(f: impl T<O=()>) {}
+
+fn main() {
+    bar(foo); //~ERROR E0277
+}
diff --git a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
new file mode 100644
index 00000000000..2e4505c7405
--- /dev/null
+++ b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `fn() -> impl T {foo}: T` is not satisfied
+  --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:17:5
+   |
+LL | fn bar(f: impl T<O=()>) {}
+   | ----------------------- required by `bar`
+...
+LL |     bar(foo);
+   |     ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}`
+   |
+   = help: it looks like you forgot to use parentheses to call the function: `foo()`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.