diff options
| author | Christian Poveda <z1mvader@protonmail.com> | 2017-05-08 16:04:49 -0500 |
|---|---|---|
| committer | Christian Poveda <z1mvader@protonmail.com> | 2017-05-08 16:04:49 -0500 |
| commit | 170c4340f66bd9843a2bfc2ccfa305cddbeb4807 (patch) | |
| tree | 2c877011c85830d0a3276be1129e11aa05823c6b | |
| parent | f096c8d17412b6303dc80cfff3dee5c2dffd16e5 (diff) | |
| download | rust-170c4340f66bd9843a2bfc2ccfa305cddbeb4807.tar.gz rust-170c4340f66bd9843a2bfc2ccfa305cddbeb4807.zip | |
dividied closure-no-fn.rs into three different tests
| -rw-r--r-- | src/test/compile-fail/closure-no-fn-1.rs (renamed from src/test/compile-fail/closure-no-fn.rs) | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/closure-no-fn-2.rs | 18 | ||||
| -rw-r--r-- | src/test/compile-fail/closure-no-fn-3.rs | 18 |
3 files changed, 36 insertions, 6 deletions
diff --git a/src/test/compile-fail/closure-no-fn.rs b/src/test/compile-fail/closure-no-fn-1.rs index fe179e8a48f..10c99703a97 100644 --- a/src/test/compile-fail/closure-no-fn.rs +++ b/src/test/compile-fail/closure-no-fn-1.rs @@ -15,10 +15,4 @@ fn main() { let mut a = 0u8; let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; //~^ ERROR mismatched types - let b = 0u8; - let bar: fn() -> u8 = || { b }; - //~^ ERROR mismatched types - let baz: fn() -> u8 = || { b } as fn() -> u8; - //~^ ERROR mismatched types - //~^^ ERROR non-scalar cast } diff --git a/src/test/compile-fail/closure-no-fn-2.rs b/src/test/compile-fail/closure-no-fn-2.rs new file mode 100644 index 00000000000..a6438bb5f24 --- /dev/null +++ b/src/test/compile-fail/closure-no-fn-2.rs @@ -0,0 +1,18 @@ +// 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. + +// Ensure that capturing closures are never coerced to fns +// Especially interesting as non-capturing closures can be. + +fn main() { + let b = 0u8; + let bar: fn() -> u8 = || { b }; + //~^ ERROR mismatched types +} diff --git a/src/test/compile-fail/closure-no-fn-3.rs b/src/test/compile-fail/closure-no-fn-3.rs new file mode 100644 index 00000000000..85dbc899208 --- /dev/null +++ b/src/test/compile-fail/closure-no-fn-3.rs @@ -0,0 +1,18 @@ +// 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. + +// Ensure that capturing closures are never coerced to fns +// Especially interesting as non-capturing closures can be. + +fn main() { + let b = 0u8; + let baz: fn() -> u8 = (|| { b }) as fn() -> u8; + //~^ ERROR non-scalar cast +} |
