From 76ceeddb2b6fd4589cf8292d8dafa65a91ace019 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 6 Sep 2018 14:36:26 +0200 Subject: Migrated remaining `src/test/run-pass/` subdirectories to `src/test/ui/run-pass/`. --- .../generator/auxiliary/xcrate-reachable.rs | 24 --- src/test/run-pass/generator/auxiliary/xcrate.rs | 27 --- src/test/run-pass/generator/borrow-in-tail-expr.rs | 19 --- src/test/run-pass/generator/conditional-drop.rs | 65 -------- src/test/run-pass/generator/control-flow.rs | 56 ------- src/test/run-pass/generator/drop-env.rs | 70 -------- src/test/run-pass/generator/issue-44197.rs | 42 ----- src/test/run-pass/generator/issue-52398.rs | 35 ---- src/test/run-pass/generator/iterator-count.rs | 50 ------ .../run-pass/generator/live-upvar-across-yield.rs | 21 --- src/test/run-pass/generator/match-bindings.rs | 30 ---- src/test/run-pass/generator/nested_generators.rs | 30 ---- src/test/run-pass/generator/panic-drops.rs | 64 -------- src/test/run-pass/generator/panic-safe.rs | 37 ----- src/test/run-pass/generator/reborrow-mut-upvar.rs | 24 --- src/test/run-pass/generator/resume-after-return.rs | 35 ---- src/test/run-pass/generator/smoke.rs | 181 --------------------- src/test/run-pass/generator/static-generators.rs | 26 --- .../generator/too-live-local-in-immovable-gen.rs | 28 ---- src/test/run-pass/generator/xcrate-reachable.rs | 21 --- src/test/run-pass/generator/xcrate.rs | 37 ----- src/test/run-pass/generator/yield-in-args-rev.rs | 26 --- src/test/run-pass/generator/yield-in-box.rs | 26 --- .../run-pass/generator/yield-in-initializer.rs | 25 --- src/test/run-pass/generator/yield-subtype.rs | 27 --- 25 files changed, 1026 deletions(-) delete mode 100644 src/test/run-pass/generator/auxiliary/xcrate-reachable.rs delete mode 100644 src/test/run-pass/generator/auxiliary/xcrate.rs delete mode 100644 src/test/run-pass/generator/borrow-in-tail-expr.rs delete mode 100644 src/test/run-pass/generator/conditional-drop.rs delete mode 100644 src/test/run-pass/generator/control-flow.rs delete mode 100644 src/test/run-pass/generator/drop-env.rs delete mode 100644 src/test/run-pass/generator/issue-44197.rs delete mode 100644 src/test/run-pass/generator/issue-52398.rs delete mode 100644 src/test/run-pass/generator/iterator-count.rs delete mode 100644 src/test/run-pass/generator/live-upvar-across-yield.rs delete mode 100644 src/test/run-pass/generator/match-bindings.rs delete mode 100644 src/test/run-pass/generator/nested_generators.rs delete mode 100644 src/test/run-pass/generator/panic-drops.rs delete mode 100644 src/test/run-pass/generator/panic-safe.rs delete mode 100644 src/test/run-pass/generator/reborrow-mut-upvar.rs delete mode 100644 src/test/run-pass/generator/resume-after-return.rs delete mode 100644 src/test/run-pass/generator/smoke.rs delete mode 100644 src/test/run-pass/generator/static-generators.rs delete mode 100644 src/test/run-pass/generator/too-live-local-in-immovable-gen.rs delete mode 100644 src/test/run-pass/generator/xcrate-reachable.rs delete mode 100644 src/test/run-pass/generator/xcrate.rs delete mode 100644 src/test/run-pass/generator/yield-in-args-rev.rs delete mode 100644 src/test/run-pass/generator/yield-in-box.rs delete mode 100644 src/test/run-pass/generator/yield-in-initializer.rs delete mode 100644 src/test/run-pass/generator/yield-subtype.rs (limited to 'src/test/run-pass/generator') diff --git a/src/test/run-pass/generator/auxiliary/xcrate-reachable.rs b/src/test/run-pass/generator/auxiliary/xcrate-reachable.rs deleted file mode 100644 index 91e43537cc2..00000000000 --- a/src/test/run-pass/generator/auxiliary/xcrate-reachable.rs +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn msg() -> u32 { - 0 -} - -pub fn foo() -> impl Generator { - || { - yield; - return msg(); - } -} diff --git a/src/test/run-pass/generator/auxiliary/xcrate.rs b/src/test/run-pass/generator/auxiliary/xcrate.rs deleted file mode 100644 index fcfe0b754b6..00000000000 --- a/src/test/run-pass/generator/auxiliary/xcrate.rs +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -pub fn foo() -> impl Generator { - || { - if false { - yield; - } - } -} - -pub fn bar(t: T) -> Box> { - Box::new(|| { - yield t; - }) -} diff --git a/src/test/run-pass/generator/borrow-in-tail-expr.rs b/src/test/run-pass/generator/borrow-in-tail-expr.rs deleted file mode 100644 index 486fe3c900d..00000000000 --- a/src/test/run-pass/generator/borrow-in-tail-expr.rs +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -#![feature(generators)] - -fn main() { - let _a = || { - yield; - let a = String::new(); - a.len() - }; -} diff --git a/src/test/run-pass/generator/conditional-drop.rs b/src/test/run-pass/generator/conditional-drop.rs deleted file mode 100644 index 3d39c46186b..00000000000 --- a/src/test/run-pass/generator/conditional-drop.rs +++ /dev/null @@ -1,65 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; - -static A: AtomicUsize = ATOMIC_USIZE_INIT; - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - - -fn test() -> bool { true } -fn test2() -> bool { false } - -fn main() { - t1(); - t2(); -} - -fn t1() { - let mut a = || { - let b = B; - if test() { - drop(b); - } - yield; - }; - - let n = A.load(Ordering::SeqCst); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n + 1); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t2() { - let mut a = || { - let b = B; - if test2() { - drop(b); - } - yield; - }; - - let n = A.load(Ordering::SeqCst); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} diff --git a/src/test/run-pass/generator/control-flow.rs b/src/test/run-pass/generator/control-flow.rs deleted file mode 100644 index 09971410e55..00000000000 --- a/src/test/run-pass/generator/control-flow.rs +++ /dev/null @@ -1,56 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; - -fn finish(mut amt: usize, mut t: T) -> T::Return - where T: Generator -{ - loop { - match unsafe { t.resume() } { - GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), - GeneratorState::Complete(ret) => { - assert_eq!(amt, 0); - return ret - } - } - } - -} - -fn main() { - finish(1, || yield); - finish(8, || { - for _ in 0..8 { - yield; - } - }); - finish(1, || { - if true { - yield; - } else { - } - }); - finish(1, || { - if false { - } else { - yield; - } - }); - finish(2, || { - if { yield; false } { - yield; - panic!() - } - yield - }); -} diff --git a/src/test/run-pass/generator/drop-env.rs b/src/test/run-pass/generator/drop-env.rs deleted file mode 100644 index ef4dc24472e..00000000000 --- a/src/test/run-pass/generator/drop-env.rs +++ /dev/null @@ -1,70 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; - -static A: AtomicUsize = ATOMIC_USIZE_INIT; - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - -fn main() { - t1(); - t2(); - t3(); -} - -fn t1() { - let b = B; - let mut foo = || { - yield; - drop(b); - }; - - let n = A.load(Ordering::SeqCst); - drop(unsafe { foo.resume() }); - assert_eq!(A.load(Ordering::SeqCst), n); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t2() { - let b = B; - let mut foo = || { - yield b; - }; - - let n = A.load(Ordering::SeqCst); - drop(unsafe { foo.resume() }); - assert_eq!(A.load(Ordering::SeqCst), n + 1); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t3() { - let b = B; - let foo = || { - yield; - drop(b); - }; - - let n = A.load(Ordering::SeqCst); - assert_eq!(A.load(Ordering::SeqCst), n); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} diff --git a/src/test/run-pass/generator/issue-44197.rs b/src/test/run-pass/generator/issue-44197.rs deleted file mode 100644 index 272b7eb7bfd..00000000000 --- a/src/test/run-pass/generator/issue-44197.rs +++ /dev/null @@ -1,42 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::{ Generator, GeneratorState }; - -fn foo(_: &str) -> String { - String::new() -} - -fn bar(baz: String) -> impl Generator { - move || { - yield foo(&baz); - } -} - -fn foo2(_: &str) -> Result { - Err(()) -} - -fn bar2(baz: String) -> impl Generator { - move || { - if let Ok(quux) = foo2(&baz) { - yield quux; - } - } -} - -fn main() { - unsafe { - assert_eq!(bar(String::new()).resume(), GeneratorState::Yielded(String::new())); - assert_eq!(bar2(String::new()).resume(), GeneratorState::Complete(())); - } -} diff --git a/src/test/run-pass/generator/issue-52398.rs b/src/test/run-pass/generator/issue-52398.rs deleted file mode 100644 index 0fb8f277ea9..00000000000 --- a/src/test/run-pass/generator/issue-52398.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 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. - -#![feature(generators)] - -use std::cell::RefCell; - -struct A; - -impl A { - fn test(&self, a: ()) {} -} - -fn main() { - // Test that the MIR local with type &A created for the auto-borrow adjustment - // is caught by typeck - move || { - A.test(yield); - }; - - // Test that the std::cell::Ref temporary returned from the `borrow` call - // is caught by typeck - let y = RefCell::new(true); - static move || { - yield *y.borrow(); - return "Done"; - }; -} diff --git a/src/test/run-pass/generator/iterator-count.rs b/src/test/run-pass/generator/iterator-count.rs deleted file mode 100644 index 3564ddaa806..00000000000 --- a/src/test/run-pass/generator/iterator-count.rs +++ /dev/null @@ -1,50 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; - -struct W(T); - -// This impl isn't safe in general, but the generator used in this test is movable -// so it won't cause problems. -impl> Iterator for W { - type Item = T::Yield; - - fn next(&mut self) -> Option { - match unsafe { self.0.resume() } { - GeneratorState::Complete(..) => None, - GeneratorState::Yielded(v) => Some(v), - } - } -} - -fn test() -> impl Generator { - || { - for i in 1..6 { - yield i - } - } -} - -fn main() { - let end = 11; - - let closure_test = |start| { - move || { - for i in start..end { - yield i - } - } - }; - - assert!(W(test()).chain(W(closure_test(6))).eq(1..11)); -} diff --git a/src/test/run-pass/generator/live-upvar-across-yield.rs b/src/test/run-pass/generator/live-upvar-across-yield.rs deleted file mode 100644 index 28e7da232ce..00000000000 --- a/src/test/run-pass/generator/live-upvar-across-yield.rs +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn main() { - let b = |_| 3; - let mut a = || { - b(yield); - }; - unsafe { a.resume() }; -} diff --git a/src/test/run-pass/generator/match-bindings.rs b/src/test/run-pass/generator/match-bindings.rs deleted file mode 100644 index 231aa1b42f0..00000000000 --- a/src/test/run-pass/generator/match-bindings.rs +++ /dev/null @@ -1,30 +0,0 @@ -// 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. - -#![feature(generators)] - -enum Enum { - A(String), - B -} - -fn main() { - || { - loop { - if let true = true { - match Enum::A(String::new()) { - Enum::A(_var) => {} - Enum::B => {} - } - } - yield; - } - }; -} diff --git a/src/test/run-pass/generator/nested_generators.rs b/src/test/run-pass/generator/nested_generators.rs deleted file mode 100644 index 29808da85a7..00000000000 --- a/src/test/run-pass/generator/nested_generators.rs +++ /dev/null @@ -1,30 +0,0 @@ -// 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. - -#![feature(generators)] -#![feature(generator_trait)] - -use std::ops::Generator; -use std::ops::GeneratorState; - -fn main() { - let _generator = || { - let mut sub_generator = || { - yield 2; - }; - - match unsafe { sub_generator.resume() } { - GeneratorState::Yielded(x) => { - yield x; - } - _ => panic!(), - }; - }; -} diff --git a/src/test/run-pass/generator/panic-drops.rs b/src/test/run-pass/generator/panic-drops.rs deleted file mode 100644 index 3d7b60ab6b9..00000000000 --- a/src/test/run-pass/generator/panic-drops.rs +++ /dev/null @@ -1,64 +0,0 @@ -// 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. - -// ignore-wasm32-bare compiled as panic=abort by default - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic; -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; - -static A: AtomicUsize = ATOMIC_USIZE_INIT; - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - -fn bool_true() -> bool { - true -} - -fn main() { - let b = B; - let mut foo = || { - if bool_true() { - panic!(); - } - drop(b); - yield; - }; - - assert_eq!(A.load(Ordering::SeqCst), 0); - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - assert_eq!(A.load(Ordering::SeqCst), 1); - - let mut foo = || { - if bool_true() { - panic!(); - } - drop(B); - yield; - }; - - assert_eq!(A.load(Ordering::SeqCst), 1); - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - assert_eq!(A.load(Ordering::SeqCst), 1); -} diff --git a/src/test/run-pass/generator/panic-safe.rs b/src/test/run-pass/generator/panic-safe.rs deleted file mode 100644 index ace5cdde51d..00000000000 --- a/src/test/run-pass/generator/panic-safe.rs +++ /dev/null @@ -1,37 +0,0 @@ -// 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. - -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic; - -fn main() { - let mut foo = || { - if true { - panic!(); - } - yield; - }; - - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - - for _ in 0..10 { - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - } -} diff --git a/src/test/run-pass/generator/reborrow-mut-upvar.rs b/src/test/run-pass/generator/reborrow-mut-upvar.rs deleted file mode 100644 index 8353066bfbe..00000000000 --- a/src/test/run-pass/generator/reborrow-mut-upvar.rs +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -#![feature(generators)] - -fn _run(bar: &mut i32) { - || { - { - let _baz = &*bar; - yield; - } - - *bar = 2; - }; -} - -fn main() {} diff --git a/src/test/run-pass/generator/resume-after-return.rs b/src/test/run-pass/generator/resume-after-return.rs deleted file mode 100644 index 06e7615d261..00000000000 --- a/src/test/run-pass/generator/resume-after-return.rs +++ /dev/null @@ -1,35 +0,0 @@ -// 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. - -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::panic; - -fn main() { - let mut foo = || { - if true { - return - } - yield; - }; - - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - match panic::catch_unwind(move || unsafe { foo.resume() }) { - Ok(_) => panic!("generator successfully resumed"), - Err(_) => {} - } -} diff --git a/src/test/run-pass/generator/smoke.rs b/src/test/run-pass/generator/smoke.rs deleted file mode 100644 index 7395c8484c1..00000000000 --- a/src/test/run-pass/generator/smoke.rs +++ /dev/null @@ -1,181 +0,0 @@ -// 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. - -// ignore-emscripten no threads support -// compile-flags: --test - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::thread; - -#[test] -fn simple() { - let mut foo = || { - if false { - yield; - } - }; - - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn return_capture() { - let a = String::from("foo"); - let mut foo = || { - if false { - yield; - } - a - }; - - match unsafe { foo.resume() } { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn simple_yield() { - let mut foo = || { - yield; - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn yield_capture() { - let b = String::from("foo"); - let mut foo = || { - yield b; - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn simple_yield_value() { - let mut foo = || { - yield String::from("bar"); - return String::from("foo") - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(ref s) if *s == "bar" => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn return_after_yield() { - let a = String::from("foo"); - let mut foo = || { - yield; - return a - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn send_and_sync() { - assert_send_sync(|| { - yield - }); - assert_send_sync(|| { - yield String::from("foo"); - }); - assert_send_sync(|| { - yield; - return String::from("foo"); - }); - let a = 3; - assert_send_sync(|| { - yield a; - return - }); - let a = 3; - assert_send_sync(move || { - yield a; - return - }); - let a = String::from("a"); - assert_send_sync(|| { - yield ; - drop(a); - return - }); - let a = String::from("a"); - assert_send_sync(move || { - yield ; - drop(a); - return - }); - - fn assert_send_sync(_: T) {} -} - -#[test] -fn send_over_threads() { - let mut foo = || { yield }; - thread::spawn(move || { - match unsafe { foo.resume() } { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - }).join().unwrap(); - - let a = String::from("a"); - let mut foo = || { yield a }; - thread::spawn(move || { - match unsafe { foo.resume() } { - GeneratorState::Yielded(ref s) if *s == "a" => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - }).join().unwrap(); -} diff --git a/src/test/run-pass/generator/static-generators.rs b/src/test/run-pass/generator/static-generators.rs deleted file mode 100644 index ebc070eee09..00000000000 --- a/src/test/run-pass/generator/static-generators.rs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; - -fn main() { - let mut generator = static || { - let a = true; - let b = &a; - yield; - assert_eq!(b as *const _, &a as *const _); - }; - unsafe { - assert_eq!(generator.resume(), GeneratorState::Yielded(())); - assert_eq!(generator.resume(), GeneratorState::Complete(())); - } -} diff --git a/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs b/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs deleted file mode 100644 index 2314533a681..00000000000 --- a/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 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. - -#![feature(generators)] - -fn main() { - unsafe { - static move || { - // Tests that the generator transformation finds out that `a` is not live - // during the yield expression. Type checking will also compute liveness - // and it should also find out that `a` is not live. - // The compiler will panic if the generator transformation finds that - // `a` is live and type checking finds it dead. - let a = { - yield (); - 4i32 - }; - &a; - }; - } -} diff --git a/src/test/run-pass/generator/xcrate-reachable.rs b/src/test/run-pass/generator/xcrate-reachable.rs deleted file mode 100644 index 2fc39ba1869..00000000000 --- a/src/test/run-pass/generator/xcrate-reachable.rs +++ /dev/null @@ -1,21 +0,0 @@ -// 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. - -// aux-build:xcrate-reachable.rs - -#![feature(generator_trait)] - -extern crate xcrate_reachable as foo; - -use std::ops::Generator; - -fn main() { - unsafe { foo::foo().resume(); } -} diff --git a/src/test/run-pass/generator/xcrate.rs b/src/test/run-pass/generator/xcrate.rs deleted file mode 100644 index 04791d51356..00000000000 --- a/src/test/run-pass/generator/xcrate.rs +++ /dev/null @@ -1,37 +0,0 @@ -// 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. - -// aux-build:xcrate.rs - -#![feature(generators, generator_trait)] - -extern crate xcrate; - -use std::ops::{GeneratorState, Generator}; - -fn main() { - let mut foo = xcrate::foo(); - - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - let mut foo = xcrate::bar(3); - - match unsafe { foo.resume() } { - GeneratorState::Yielded(3) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} diff --git a/src/test/run-pass/generator/yield-in-args-rev.rs b/src/test/run-pass/generator/yield-in-args-rev.rs deleted file mode 100644 index df00329799e..00000000000 --- a/src/test/run-pass/generator/yield-in-args-rev.rs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -// Test that a borrow that occurs after a yield in the same -// argument list is not treated as live across the yield by -// type-checking. - -#![feature(generators)] - -fn foo(_a: (), _b: &bool) {} - -fn bar() { - || { - let b = true; - foo(yield, &b); - }; -} - -fn main() { } diff --git a/src/test/run-pass/generator/yield-in-box.rs b/src/test/run-pass/generator/yield-in-box.rs deleted file mode 100644 index d68007be05c..00000000000 --- a/src/test/run-pass/generator/yield-in-box.rs +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -// Test that box-statements with yields in them work. - -#![feature(generators, box_syntax)] - -fn main() { - let x = 0i32; - || { - let y = 2u32; - { - let _t = box (&x, yield 0, &y); - } - match box (&x, yield 0, &y) { - _t => {} - } - }; -} diff --git a/src/test/run-pass/generator/yield-in-initializer.rs b/src/test/run-pass/generator/yield-in-initializer.rs deleted file mode 100644 index 3042061226b..00000000000 --- a/src/test/run-pass/generator/yield-in-initializer.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 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. - -#![feature(generators)] - -fn main() { - static || { - loop { - // Test that `opt` is not live across the yield, even when borrowed in a loop - // See https://github.com/rust-lang/rust/issues/52792 - let opt = { - yield; - true - }; - &opt; - } - }; -} diff --git a/src/test/run-pass/generator/yield-subtype.rs b/src/test/run-pass/generator/yield-subtype.rs deleted file mode 100644 index c4134169044..00000000000 --- a/src/test/run-pass/generator/yield-subtype.rs +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -// revisions:lexical nll -//[nll]compile-flags: -Z disable-nll-user-type-assert -#![cfg_attr(nll, feature(nll))] - -#![feature(generators)] - -fn bar<'a>() { - let a: &'static str = "hi"; - let b: &'a str = a; - - || { - yield a; - yield b; - }; -} - -fn main() {} -- cgit 1.4.1-3-g733a5