diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2017-09-03 12:43:05 +0200 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-09-20 16:36:24 +0300 |
| commit | 3a511e06a5949ed9fbc552c161fcbe0cf17e5e2c (patch) | |
| tree | ad23a50f1013e9b7300b6d5f9441fc8b90baa5e1 /src/test | |
| parent | 1e6ec9f33a82886e45d2fd9abb4eddaf15496920 (diff) | |
| download | rust-3a511e06a5949ed9fbc552c161fcbe0cf17e5e2c.tar.gz rust-3a511e06a5949ed9fbc552c161fcbe0cf17e5e2c.zip | |
Only consider yields coming after the expressions when computing generator interiors
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/generator/borrow-in-tail-expr.rs | 19 | ||||
| -rw-r--r-- | src/test/run-pass/generator/borrow-in-yield-expr.rs | 21 | ||||
| -rw-r--r-- | src/test/run-pass/generator/yield-in-args-rev.rs (renamed from src/test/ui/generator/yield-in-args-rev.rs) | 4 | ||||
| -rw-r--r-- | src/test/ui/generator/yield-in-args-rev.stderr | 10 |
4 files changed, 41 insertions, 13 deletions
diff --git a/src/test/run-pass/generator/borrow-in-tail-expr.rs b/src/test/run-pass/generator/borrow-in-tail-expr.rs new file mode 100644 index 00000000000..df1a1dcebe6 --- /dev/null +++ b/src/test/run-pass/generator/borrow-in-tail-expr.rs @@ -0,0 +1,19 @@ +// 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. + +#![feature(generators)] + +fn main() { + let _a = || { + yield; + let a = String::new(); + a.len() + }; +} \ No newline at end of file diff --git a/src/test/run-pass/generator/borrow-in-yield-expr.rs b/src/test/run-pass/generator/borrow-in-yield-expr.rs new file mode 100644 index 00000000000..50981df7566 --- /dev/null +++ b/src/test/run-pass/generator/borrow-in-yield-expr.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. + +#![feature(generators, generator_trait, conservative_impl_trait)] + +use std::ops::Generator; + +fn bar(baz: String) -> impl Generator<Yield=(), Return=()> { + move || { + yield drop(&baz); + } +} + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/generator/yield-in-args-rev.rs b/src/test/run-pass/generator/yield-in-args-rev.rs index fb0e68136f5..e22759291d1 100644 --- a/src/test/ui/generator/yield-in-args-rev.rs +++ b/src/test/run-pass/generator/yield-in-args-rev.rs @@ -12,12 +12,10 @@ fn foo(_a: (), _b: &bool) {} -// Some examples that probably *could* be accepted, but which we reject for now. - fn bar() { || { let b = true; - foo(yield, &b); //~ ERROR + foo(yield, &b); }; } diff --git a/src/test/ui/generator/yield-in-args-rev.stderr b/src/test/ui/generator/yield-in-args-rev.stderr deleted file mode 100644 index 157f8968209..00000000000 --- a/src/test/ui/generator/yield-in-args-rev.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-in-args-rev.rs:20:21 - | -20 | foo(yield, &b); //~ ERROR - | ----- ^ - | | - | possible yield occurs here - -error: aborting due to previous error - |
