From a80840f75196b69ea3f6c8b1fdaa032be609e9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 15 Jun 2017 02:09:53 +0200 Subject: [PATCH] Added more tests --- .../for-loop-unconstrained-element-type.rs | 13 +++++++++++++ .../for-loop-lifetime-of-unbound-values.rs | 2 +- ...op-unconstrained-element-type-i32-fallback.rs | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/for-loop-unconstrained-element-type.rs create mode 100644 src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs diff --git a/src/test/compile-fail/for-loop-unconstrained-element-type.rs b/src/test/compile-fail/for-loop-unconstrained-element-type.rs new file mode 100644 index 000000000000..f7dccc7f2ac1 --- /dev/null +++ b/src/test/compile-fail/for-loop-unconstrained-element-type.rs @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + for i in Vec::new() { } //~ ERROR type annotations needed +} diff --git a/src/test/run-pass/for-loop-lifetime-of-unbound-values.rs b/src/test/run-pass/for-loop-lifetime-of-unbound-values.rs index a0562edfadd6..4653a493898e 100644 --- a/src/test/run-pass/for-loop-lifetime-of-unbound-values.rs +++ b/src/test/run-pass/for-loop-lifetime-of-unbound-values.rs @@ -35,4 +35,4 @@ fn main() { } // The Flag value should be dead outside of the loop assert_eq!(alive.get(), false); -} \ No newline at end of file +} diff --git a/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs b/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs new file mode 100644 index 000000000000..d9a876d9c952 --- /dev/null +++ b/src/test/run-pass/for-loop-unconstrained-element-type-i32-fallback.rs @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let mut sum = 0; + for i in Vec::new() { + sum += i; + } +}