diff options
| author | Tommy Ip <hkmp7tommy@gmail.com> | 2017-06-06 09:17:06 +0100 |
|---|---|---|
| committer | Tommy Ip <hkmp7tommy@gmail.com> | 2017-06-06 09:17:06 +0100 |
| commit | 2c282b8e5d0b592f72e9fd3c6038c8e2e80d6055 (patch) | |
| tree | c198463c047290ca5964d9c641a84fae3d483d38 | |
| parent | 94c808c1d3fbf6f73b2bfdb8d6fbcad1d260fe64 (diff) | |
| download | rust-2c282b8e5d0b592f72e9fd3c6038c8e2e80d6055.tar.gz rust-2c282b8e5d0b592f72e9fd3c6038c8e2e80d6055.zip | |
Add additional ui tests for issue 26046
This tests the FnMut case.
| -rw-r--r-- | src/test/ui/issue-26046-fn-mut.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/issue-26046-fn-mut.stderr | 17 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/issue-26046-fn-mut.rs b/src/test/ui/issue-26046-fn-mut.rs new file mode 100644 index 00000000000..5ed7ace5437 --- /dev/null +++ b/src/test/ui/issue-26046-fn-mut.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 foo() -> Box<Fn()> { + let num = 5; + + let closure = || { + num += 1; + }; + + Box::new(closure) +} + +fn main() {} diff --git a/src/test/ui/issue-26046-fn-mut.stderr b/src/test/ui/issue-26046-fn-mut.stderr new file mode 100644 index 00000000000..4dd33ef8a0e --- /dev/null +++ b/src/test/ui/issue-26046-fn-mut.stderr @@ -0,0 +1,17 @@ +error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnMut` + --> $DIR/issue-26046-fn-mut.rs:14:19 + | +14 | let closure = || { + | ___________________^ +15 | | num += 1; +16 | | }; + | |_____^ + | +note: closure is `FnMut` because it mutates the variable `num` here + --> $DIR/issue-26046-fn-mut.rs:15:9 + | +15 | num += 1; + | ^^^ + +error: aborting due to previous error(s) + |
