about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTommy Ip <hkmp7tommy@gmail.com>2017-06-05 11:35:17 +0100
committerTommy Ip <hkmp7tommy@gmail.com>2017-06-05 12:02:12 +0100
commit9cbb5f9a245f859c94d90acebef02adbc4a807e3 (patch)
tree672009d1d9230a7ca80a2b352121fc37993ebc6f
parent9d188e680e5558af2842231e6c32a676afc0086b (diff)
downloadrust-9cbb5f9a245f859c94d90acebef02adbc4a807e3.tar.gz
rust-9cbb5f9a245f859c94d90acebef02adbc4a807e3.zip
Add ui tests for issue 26046
-rw-r--r--src/test/ui/issue-26046.rs21
-rw-r--r--src/test/ui/issue-26046.stderr17
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/issue-26046.rs b/src/test/ui/issue-26046.rs
new file mode 100644
index 00000000000..de06de530c6
--- /dev/null
+++ b/src/test/ui/issue-26046.rs
@@ -0,0 +1,21 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn get_closure() -> Box<Fn() -> Vec<u8>> {
+    let vec = vec![1u8, 2u8];
+
+    let closure = move || {
+        vec
+    };
+
+    Box::new(closure)
+}
+
+fn main() {}
diff --git a/src/test/ui/issue-26046.stderr b/src/test/ui/issue-26046.stderr
new file mode 100644
index 00000000000..fa3681dc01f
--- /dev/null
+++ b/src/test/ui/issue-26046.stderr
@@ -0,0 +1,17 @@
+error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce`
+  --> $DIR/issue-26046.rs:14:19
+   |
+14 |       let closure = move || {
+   |  ___________________^
+15 | |         vec
+16 | |     };
+   | |_____^
+   |
+note: closure is `FnOnce` because it moves the variable `vec` out of its environment
+  --> $DIR/issue-26046.rs:15:9
+   |
+15 |         vec
+   |         ^^^
+
+error: aborting due to previous error(s)
+