diff options
| author | bors <bors@rust-lang.org> | 2017-06-04 05:44:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-06-04 05:44:39 +0000 |
| commit | 0b17b4c0846d0e01544e90bb2aa2776576e825d1 (patch) | |
| tree | 0e280de282d4988b39ab3ef4a08fe188f6e70561 /src/test/compile-fail | |
| parent | 1b5a923001c481627d7b1d19d0fe1d3f86e5c5a6 (diff) | |
| parent | cfdbff7c125cbdd5a2b75e526717413718d16111 (diff) | |
| download | rust-0b17b4c0846d0e01544e90bb2aa2776576e825d1.tar.gz rust-0b17b4c0846d0e01544e90bb2aa2776576e825d1.zip | |
Auto merge of #42265 - Zoxc:for-sugar, r=eddyb
Change for-loop desugar to not borrow the iterator during the loop This is enables the use of suspend points inside for-loops in movable generators. This is illegal in the current desugaring as `iter` is borrowed across the body.
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/E0297.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/for-loop-has-unit-body.rs | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/test/compile-fail/E0297.rs b/src/test/compile-fail/E0297.rs index 5792ba06eb0..436e4c1f9d2 100644 --- a/src/test/compile-fail/E0297.rs +++ b/src/test/compile-fail/E0297.rs @@ -12,6 +12,6 @@ fn main() { let xs : Vec<Option<i32>> = vec![Some(1), None]; for Some(x) in xs {} - //~^ ERROR E0297 + //~^ ERROR E0005 //~| NOTE pattern `None` not covered } diff --git a/src/test/compile-fail/for-loop-has-unit-body.rs b/src/test/compile-fail/for-loop-has-unit-body.rs new file mode 100644 index 00000000000..8c61fc602e0 --- /dev/null +++ b/src/test/compile-fail/for-loop-has-unit-body.rs @@ -0,0 +1,17 @@ +// 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 main() { + for x in 0..3 { + x //~ ERROR mismatched types + //~| NOTE expected () + //~| NOTE expected type `()` + } +} |
