about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs17
-rw-r--r--tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr18
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs
new file mode 100644
index 00000000000..ba473653ecf
--- /dev/null
+++ b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.rs
@@ -0,0 +1,17 @@
+// compile-flags: -Ztrait-solver=next
+
+#![feature(fn_traits)]
+#![feature(unboxed_closures)]
+#![feature(tuple_trait)]
+
+use std::ops::Fn;
+use std::marker::Tuple;
+
+fn foo<F: Fn<T>, T: Tuple>(f: Option<F>, t: T) {
+    let y = (f.unwrap()).call(t);
+}
+
+fn main() {
+    foo::<fn() -> str, _>(None, ());
+    //~^ expected a `Fn<_>` closure, found `fn() -> str`
+}
diff --git a/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr
new file mode 100644
index 00000000000..f7551739b13
--- /dev/null
+++ b/tests/ui/traits/new-solver/builtin-fn-must-return-sized.stderr
@@ -0,0 +1,18 @@
+error[E0277]: expected a `Fn<_>` closure, found `fn() -> str`
+  --> $DIR/builtin-fn-must-return-sized.rs:15:27
+   |
+LL |     foo::<fn() -> str, _>(None, ());
+   |     --------------------- ^^^^ expected an `Fn<_>` closure, found `fn() -> str`
+   |     |
+   |     required by a bound introduced by this call
+   |
+   = help: the trait `Fn<_>` is not implemented for `fn() -> str`
+note: required by a bound in `foo`
+  --> $DIR/builtin-fn-must-return-sized.rs:10:11
+   |
+LL | fn foo<F: Fn<T>, T: Tuple>(f: Option<F>, t: T) {
+   |           ^^^^^ required by this bound in `foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.