about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-10-22 17:00:47 +0900
committerYuki Okushi <huyuumi.dev@gmail.com>2019-10-22 17:05:03 +0900
commita239c8dfb29c20f29fc3b30959f654d41fb0dd7f (patch)
tree2cc4a645046b56c6b4f55f397385fd3a57ce7ce7
parent50ffa79589600f515ff2710830c23cd2dce7cb76 (diff)
downloadrust-a239c8dfb29c20f29fc3b30959f654d41fb0dd7f.tar.gz
rust-a239c8dfb29c20f29fc3b30959f654d41fb0dd7f.zip
Add test for issue-41366
-rw-r--r--src/test/ui/closures/issue-41366.rs13
-rw-r--r--src/test/ui/closures/issue-41366.stderr22
2 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/closures/issue-41366.rs b/src/test/ui/closures/issue-41366.rs
new file mode 100644
index 00000000000..5cae0e76d1a
--- /dev/null
+++ b/src/test/ui/closures/issue-41366.rs
@@ -0,0 +1,13 @@
+trait T<'x> {
+    type V;
+}
+
+impl<'g> T<'g> for u32 {
+    type V = u16;
+}
+
+fn main() {
+    (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
+    //~^ ERROR: type mismatch in closure arguments
+    //~| ERROR: type mismatch resolving
+}
diff --git a/src/test/ui/closures/issue-41366.stderr b/src/test/ui/closures/issue-41366.stderr
new file mode 100644
index 00000000000..91d26efbc4f
--- /dev/null
+++ b/src/test/ui/closures/issue-41366.stderr
@@ -0,0 +1,22 @@
+error[E0631]: type mismatch in closure arguments
+  --> $DIR/issue-41366.rs:10:5
+   |
+LL |     (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
+   |     ^^-----^
+   |     | |
+   |     | found signature of `fn(_) -> _`
+   |     expected signature of `for<'x> fn(<u32 as T<'x>>::V) -> _`
+   |
+   = note: required for the cast to the object type `dyn for<'x> std::ops::Fn(<u32 as T<'x>>::V)`
+
+error[E0271]: type mismatch resolving `for<'x> <[closure@$DIR/issue-41366.rs:10:7: 10:12] as std::ops::FnOnce<(<u32 as T<'x>>::V,)>>::Output == ()`
+  --> $DIR/issue-41366.rs:10:5
+   |
+LL |     (&|_|()) as &dyn for<'x> Fn(<u32 as T<'x>>::V);
+   |     ^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime
+   |
+   = note: required for the cast to the object type `dyn for<'x> std::ops::Fn(<u32 as T<'x>>::V)`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0271`.