From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/generator/addassign-yield.rs | 35 ---- .../ui/generator/async-generator-issue-67158.rs | 6 - .../generator/async-generator-issue-67158.stderr | 9 -- src/test/ui/generator/auto-trait-regions.rs | 53 ------ src/test/ui/generator/auto-trait-regions.stderr | 47 ------ .../auxiliary/metadata-sufficient-for-layout.rs | 11 -- .../ui/generator/auxiliary/xcrate-reachable.rs | 14 -- src/test/ui/generator/auxiliary/xcrate.rs | 18 --- src/test/ui/generator/borrow-in-tail-expr.rs | 11 -- src/test/ui/generator/borrowing.rs | 20 --- src/test/ui/generator/borrowing.stderr | 31 ---- src/test/ui/generator/clone-impl-async.rs | 70 -------- src/test/ui/generator/clone-impl-async.stderr | 171 -------------------- src/test/ui/generator/clone-impl-static.rs | 17 -- src/test/ui/generator/clone-impl-static.stderr | 31 ---- src/test/ui/generator/clone-impl.rs | 73 --------- src/test/ui/generator/clone-impl.stderr | 142 ----------------- src/test/ui/generator/conditional-drop.rs | 61 ------- src/test/ui/generator/control-flow.rs | 53 ------ src/test/ui/generator/derived-drop-parent-expr.rs | 17 -- src/test/ui/generator/discriminant.rs | 137 ---------------- src/test/ui/generator/drop-and-replace.rs | 45 ------ src/test/ui/generator/drop-control-flow.rs | 139 ---------------- src/test/ui/generator/drop-env.rs | 66 -------- .../ui/generator/drop-track-addassign-yield.rs | 41 ----- .../generator/drop-tracking-parent-expression.rs | 69 -------- .../drop-tracking-parent-expression.stderr | 128 --------------- .../drop-tracking-yielding-in-match-guards.rs | 12 -- src/test/ui/generator/drop-yield-twice.rs | 15 -- src/test/ui/generator/drop-yield-twice.stderr | 31 ---- src/test/ui/generator/dropck-resume.rs | 33 ---- src/test/ui/generator/dropck-resume.stderr | 15 -- src/test/ui/generator/dropck.rs | 20 --- src/test/ui/generator/dropck.stderr | 34 ---- .../generator-region-requirements.migrate.stderr | 12 -- .../ui/generator/generator-region-requirements.rs | 19 --- .../generator/generator-region-requirements.stderr | 11 -- .../ui/generator/generator-resume-after-panic.rs | 25 --- src/test/ui/generator/generator-with-nll.rs | 12 -- src/test/ui/generator/generator-with-nll.stderr | 12 -- .../generator-yielding-or-returning-itself.rs | 35 ---- .../generator-yielding-or-returning-itself.stderr | 53 ------ src/test/ui/generator/issue-102645.rs | 23 --- src/test/ui/generator/issue-102645.stderr | 19 --- src/test/ui/generator/issue-44197.rs | 36 ----- .../issue-45729-unsafe-in-generator.mir.stderr | 11 -- .../generator/issue-45729-unsafe-in-generator.rs | 12 -- .../issue-45729-unsafe-in-generator.thir.stderr | 11 -- src/test/ui/generator/issue-48048.rs | 13 -- src/test/ui/generator/issue-48048.stderr | 11 -- src/test/ui/generator/issue-52304.rs | 11 -- src/test/ui/generator/issue-52398.rs | 28 ---- src/test/ui/generator/issue-52398.stderr | 24 --- src/test/ui/generator/issue-53548-1.rs | 20 --- src/test/ui/generator/issue-53548.rs | 38 ----- src/test/ui/generator/issue-57017.rs | 55 ------- src/test/ui/generator/issue-57084.rs | 28 ---- src/test/ui/generator/issue-57084.stderr | 16 -- src/test/ui/generator/issue-57478.rs | 17 -- src/test/ui/generator/issue-58888.rs | 28 ---- .../generator/issue-61442-stmt-expr-with-drop.rs | 32 ---- src/test/ui/generator/issue-62506-two_awaits.rs | 17 -- .../generator/issue-64620-yield-array-element.rs | 9 -- .../issue-64620-yield-array-element.stderr | 9 -- src/test/ui/generator/issue-68112.rs | 71 --------- src/test/ui/generator/issue-68112.stderr | 64 -------- src/test/ui/generator/issue-69017.rs | 18 --- src/test/ui/generator/issue-69039.rs | 34 ---- src/test/ui/generator/issue-87142.rs | 32 ---- src/test/ui/generator/issue-88653.rs | 22 --- src/test/ui/generator/issue-88653.stderr | 15 -- src/test/ui/generator/issue-91477.rs | 7 - src/test/ui/generator/issue-91477.stderr | 9 -- src/test/ui/generator/issue-93161.rs | 94 ----------- src/test/ui/generator/iterator-count.rs | 44 ----- src/test/ui/generator/layout-error.rs | 28 ---- src/test/ui/generator/layout-error.stderr | 9 -- src/test/ui/generator/live-upvar-across-yield.rs | 14 -- src/test/ui/generator/match-bindings.rs | 23 --- src/test/ui/generator/match-bindings.stderr | 17 -- .../ui/generator/metadata-sufficient-for-layout.rs | 25 --- .../metadata-sufficient-for-layout.stderr | 8 - src/test/ui/generator/nested_generators.rs | 21 --- src/test/ui/generator/niche-in-generator.rs | 19 --- src/test/ui/generator/non-static-is-unpin.rs | 18 --- src/test/ui/generator/not-send-sync.rs | 21 --- src/test/ui/generator/not-send-sync.stderr | 56 ------- src/test/ui/generator/overlap-locals.rs | 29 ---- src/test/ui/generator/panic-drops-resume.rs | 36 ----- src/test/ui/generator/panic-drops.rs | 57 ------- src/test/ui/generator/panic-safe.rs | 30 ---- src/test/ui/generator/partial-drop.rs | 42 ----- src/test/ui/generator/partial-drop.stderr | 92 ----------- .../partial-initialization-across-yield.rs | 43 ----- .../partial-initialization-across-yield.stderr | 33 ---- src/test/ui/generator/pattern-borrow.rs | 17 -- src/test/ui/generator/pattern-borrow.stderr | 11 -- src/test/ui/generator/pin-box-generator.rs | 13 -- .../generator/print/generator-print-verbose-1.rs | 60 ------- .../print/generator-print-verbose-1.stderr | 62 -------- .../generator/print/generator-print-verbose-2.rs | 24 --- .../print/generator-print-verbose-2.stderr | 56 ------- .../generator/print/generator-print-verbose-3.rs | 12 -- .../print/generator-print-verbose-3.stderr | 19 --- src/test/ui/generator/reborrow-mut-upvar.rs | 16 -- src/test/ui/generator/reborrow-mut-upvar.stderr | 17 -- .../ui/generator/ref-escapes-but-not-over-yield.rs | 16 -- .../ref-escapes-but-not-over-yield.stderr | 15 -- src/test/ui/generator/reinit-in-match-guard.rs | 25 --- src/test/ui/generator/resume-after-return.rs | 28 ---- src/test/ui/generator/resume-arg-late-bound.rs | 17 -- src/test/ui/generator/resume-arg-late-bound.stderr | 17 -- src/test/ui/generator/resume-arg-size.rs | 28 ---- src/test/ui/generator/resume-live-across-yield.rs | 45 ------ src/test/ui/generator/retain-resume-ref.rs | 25 --- src/test/ui/generator/retain-resume-ref.stderr | 13 -- src/test/ui/generator/size-moved-locals.rs | 78 --------- src/test/ui/generator/sized-yield.rs | 14 -- src/test/ui/generator/sized-yield.stderr | 29 ---- src/test/ui/generator/smoke-resume-args.rs | 100 ------------ src/test/ui/generator/smoke.rs | 177 --------------------- src/test/ui/generator/static-generators.rs | 20 --- .../generator/static-mut-reference-across-yield.rs | 32 ---- src/test/ui/generator/static-not-unpin.rs | 15 -- src/test/ui/generator/static-not-unpin.stderr | 18 --- .../ui/generator/static-reference-across-yield.rs | 16 -- .../generator/too-live-local-in-immovable-gen.rs | 21 --- .../too-live-local-in-immovable-gen.stderr | 17 -- src/test/ui/generator/too-many-parameters.rs | 8 - src/test/ui/generator/too-many-parameters.stderr | 9 -- src/test/ui/generator/type-mismatch-error.rs | 22 --- src/test/ui/generator/type-mismatch-error.stderr | 19 --- .../generator/type-mismatch-signature-deduction.rs | 18 --- .../type-mismatch-signature-deduction.stderr | 33 ---- src/test/ui/generator/unresolved-ct-var.rs | 14 -- src/test/ui/generator/unresolved-ct-var.stderr | 78 --------- src/test/ui/generator/xcrate-reachable.rs | 14 -- src/test/ui/generator/xcrate.rs | 30 ---- src/test/ui/generator/yield-in-args-rev.rs | 19 --- src/test/ui/generator/yield-in-args-rev.stderr | 14 -- src/test/ui/generator/yield-in-args.rs | 10 -- src/test/ui/generator/yield-in-args.stderr | 9 -- src/test/ui/generator/yield-in-box.rs | 24 --- src/test/ui/generator/yield-in-box.stderr | 17 -- src/test/ui/generator/yield-in-const.rs | 6 - src/test/ui/generator/yield-in-const.stderr | 9 -- src/test/ui/generator/yield-in-function.rs | 4 - src/test/ui/generator/yield-in-function.stderr | 9 -- src/test/ui/generator/yield-in-initializer.rs | 17 -- src/test/ui/generator/yield-in-initializer.stderr | 17 -- src/test/ui/generator/yield-in-static.rs | 6 - src/test/ui/generator/yield-in-static.stderr | 9 -- .../yield-outside-generator-issue-78653.rs | 7 - .../yield-outside-generator-issue-78653.stderr | 20 --- src/test/ui/generator/yield-subtype.rs | 17 -- src/test/ui/generator/yield-subtype.stderr | 14 -- src/test/ui/generator/yield-while-iterating.rs | 75 --------- src/test/ui/generator/yield-while-iterating.stderr | 25 --- .../ui/generator/yield-while-local-borrowed.rs | 49 ------ .../ui/generator/yield-while-local-borrowed.stderr | 21 --- .../ui/generator/yield-while-ref-reborrowed.rs | 40 ----- .../ui/generator/yield-while-ref-reborrowed.stderr | 18 --- src/test/ui/generator/yielding-in-match-guards.rs | 53 ------ 163 files changed, 5180 deletions(-) delete mode 100644 src/test/ui/generator/addassign-yield.rs delete mode 100644 src/test/ui/generator/async-generator-issue-67158.rs delete mode 100644 src/test/ui/generator/async-generator-issue-67158.stderr delete mode 100644 src/test/ui/generator/auto-trait-regions.rs delete mode 100644 src/test/ui/generator/auto-trait-regions.stderr delete mode 100644 src/test/ui/generator/auxiliary/metadata-sufficient-for-layout.rs delete mode 100644 src/test/ui/generator/auxiliary/xcrate-reachable.rs delete mode 100644 src/test/ui/generator/auxiliary/xcrate.rs delete mode 100644 src/test/ui/generator/borrow-in-tail-expr.rs delete mode 100644 src/test/ui/generator/borrowing.rs delete mode 100644 src/test/ui/generator/borrowing.stderr delete mode 100644 src/test/ui/generator/clone-impl-async.rs delete mode 100644 src/test/ui/generator/clone-impl-async.stderr delete mode 100644 src/test/ui/generator/clone-impl-static.rs delete mode 100644 src/test/ui/generator/clone-impl-static.stderr delete mode 100644 src/test/ui/generator/clone-impl.rs delete mode 100644 src/test/ui/generator/clone-impl.stderr delete mode 100644 src/test/ui/generator/conditional-drop.rs delete mode 100644 src/test/ui/generator/control-flow.rs delete mode 100644 src/test/ui/generator/derived-drop-parent-expr.rs delete mode 100644 src/test/ui/generator/discriminant.rs delete mode 100644 src/test/ui/generator/drop-and-replace.rs delete mode 100644 src/test/ui/generator/drop-control-flow.rs delete mode 100644 src/test/ui/generator/drop-env.rs delete mode 100644 src/test/ui/generator/drop-track-addassign-yield.rs delete mode 100644 src/test/ui/generator/drop-tracking-parent-expression.rs delete mode 100644 src/test/ui/generator/drop-tracking-parent-expression.stderr delete mode 100644 src/test/ui/generator/drop-tracking-yielding-in-match-guards.rs delete mode 100644 src/test/ui/generator/drop-yield-twice.rs delete mode 100644 src/test/ui/generator/drop-yield-twice.stderr delete mode 100644 src/test/ui/generator/dropck-resume.rs delete mode 100644 src/test/ui/generator/dropck-resume.stderr delete mode 100644 src/test/ui/generator/dropck.rs delete mode 100644 src/test/ui/generator/dropck.stderr delete mode 100644 src/test/ui/generator/generator-region-requirements.migrate.stderr delete mode 100644 src/test/ui/generator/generator-region-requirements.rs delete mode 100644 src/test/ui/generator/generator-region-requirements.stderr delete mode 100644 src/test/ui/generator/generator-resume-after-panic.rs delete mode 100644 src/test/ui/generator/generator-with-nll.rs delete mode 100644 src/test/ui/generator/generator-with-nll.stderr delete mode 100644 src/test/ui/generator/generator-yielding-or-returning-itself.rs delete mode 100644 src/test/ui/generator/generator-yielding-or-returning-itself.stderr delete mode 100644 src/test/ui/generator/issue-102645.rs delete mode 100644 src/test/ui/generator/issue-102645.stderr delete mode 100644 src/test/ui/generator/issue-44197.rs delete mode 100644 src/test/ui/generator/issue-45729-unsafe-in-generator.mir.stderr delete mode 100644 src/test/ui/generator/issue-45729-unsafe-in-generator.rs delete mode 100644 src/test/ui/generator/issue-45729-unsafe-in-generator.thir.stderr delete mode 100644 src/test/ui/generator/issue-48048.rs delete mode 100644 src/test/ui/generator/issue-48048.stderr delete mode 100644 src/test/ui/generator/issue-52304.rs delete mode 100644 src/test/ui/generator/issue-52398.rs delete mode 100644 src/test/ui/generator/issue-52398.stderr delete mode 100644 src/test/ui/generator/issue-53548-1.rs delete mode 100644 src/test/ui/generator/issue-53548.rs delete mode 100644 src/test/ui/generator/issue-57017.rs delete mode 100644 src/test/ui/generator/issue-57084.rs delete mode 100644 src/test/ui/generator/issue-57084.stderr delete mode 100644 src/test/ui/generator/issue-57478.rs delete mode 100644 src/test/ui/generator/issue-58888.rs delete mode 100644 src/test/ui/generator/issue-61442-stmt-expr-with-drop.rs delete mode 100644 src/test/ui/generator/issue-62506-two_awaits.rs delete mode 100644 src/test/ui/generator/issue-64620-yield-array-element.rs delete mode 100644 src/test/ui/generator/issue-64620-yield-array-element.stderr delete mode 100644 src/test/ui/generator/issue-68112.rs delete mode 100644 src/test/ui/generator/issue-68112.stderr delete mode 100644 src/test/ui/generator/issue-69017.rs delete mode 100644 src/test/ui/generator/issue-69039.rs delete mode 100644 src/test/ui/generator/issue-87142.rs delete mode 100644 src/test/ui/generator/issue-88653.rs delete mode 100644 src/test/ui/generator/issue-88653.stderr delete mode 100644 src/test/ui/generator/issue-91477.rs delete mode 100644 src/test/ui/generator/issue-91477.stderr delete mode 100644 src/test/ui/generator/issue-93161.rs delete mode 100644 src/test/ui/generator/iterator-count.rs delete mode 100644 src/test/ui/generator/layout-error.rs delete mode 100644 src/test/ui/generator/layout-error.stderr delete mode 100644 src/test/ui/generator/live-upvar-across-yield.rs delete mode 100644 src/test/ui/generator/match-bindings.rs delete mode 100644 src/test/ui/generator/match-bindings.stderr delete mode 100644 src/test/ui/generator/metadata-sufficient-for-layout.rs delete mode 100644 src/test/ui/generator/metadata-sufficient-for-layout.stderr delete mode 100644 src/test/ui/generator/nested_generators.rs delete mode 100644 src/test/ui/generator/niche-in-generator.rs delete mode 100644 src/test/ui/generator/non-static-is-unpin.rs delete mode 100644 src/test/ui/generator/not-send-sync.rs delete mode 100644 src/test/ui/generator/not-send-sync.stderr delete mode 100644 src/test/ui/generator/overlap-locals.rs delete mode 100644 src/test/ui/generator/panic-drops-resume.rs delete mode 100644 src/test/ui/generator/panic-drops.rs delete mode 100644 src/test/ui/generator/panic-safe.rs delete mode 100644 src/test/ui/generator/partial-drop.rs delete mode 100644 src/test/ui/generator/partial-drop.stderr delete mode 100644 src/test/ui/generator/partial-initialization-across-yield.rs delete mode 100644 src/test/ui/generator/partial-initialization-across-yield.stderr delete mode 100644 src/test/ui/generator/pattern-borrow.rs delete mode 100644 src/test/ui/generator/pattern-borrow.stderr delete mode 100644 src/test/ui/generator/pin-box-generator.rs delete mode 100644 src/test/ui/generator/print/generator-print-verbose-1.rs delete mode 100644 src/test/ui/generator/print/generator-print-verbose-1.stderr delete mode 100644 src/test/ui/generator/print/generator-print-verbose-2.rs delete mode 100644 src/test/ui/generator/print/generator-print-verbose-2.stderr delete mode 100644 src/test/ui/generator/print/generator-print-verbose-3.rs delete mode 100644 src/test/ui/generator/print/generator-print-verbose-3.stderr delete mode 100644 src/test/ui/generator/reborrow-mut-upvar.rs delete mode 100644 src/test/ui/generator/reborrow-mut-upvar.stderr delete mode 100644 src/test/ui/generator/ref-escapes-but-not-over-yield.rs delete mode 100644 src/test/ui/generator/ref-escapes-but-not-over-yield.stderr delete mode 100644 src/test/ui/generator/reinit-in-match-guard.rs delete mode 100644 src/test/ui/generator/resume-after-return.rs delete mode 100644 src/test/ui/generator/resume-arg-late-bound.rs delete mode 100644 src/test/ui/generator/resume-arg-late-bound.stderr delete mode 100644 src/test/ui/generator/resume-arg-size.rs delete mode 100644 src/test/ui/generator/resume-live-across-yield.rs delete mode 100644 src/test/ui/generator/retain-resume-ref.rs delete mode 100644 src/test/ui/generator/retain-resume-ref.stderr delete mode 100644 src/test/ui/generator/size-moved-locals.rs delete mode 100644 src/test/ui/generator/sized-yield.rs delete mode 100644 src/test/ui/generator/sized-yield.stderr delete mode 100644 src/test/ui/generator/smoke-resume-args.rs delete mode 100644 src/test/ui/generator/smoke.rs delete mode 100644 src/test/ui/generator/static-generators.rs delete mode 100644 src/test/ui/generator/static-mut-reference-across-yield.rs delete mode 100644 src/test/ui/generator/static-not-unpin.rs delete mode 100644 src/test/ui/generator/static-not-unpin.stderr delete mode 100644 src/test/ui/generator/static-reference-across-yield.rs delete mode 100644 src/test/ui/generator/too-live-local-in-immovable-gen.rs delete mode 100644 src/test/ui/generator/too-live-local-in-immovable-gen.stderr delete mode 100644 src/test/ui/generator/too-many-parameters.rs delete mode 100644 src/test/ui/generator/too-many-parameters.stderr delete mode 100644 src/test/ui/generator/type-mismatch-error.rs delete mode 100644 src/test/ui/generator/type-mismatch-error.stderr delete mode 100644 src/test/ui/generator/type-mismatch-signature-deduction.rs delete mode 100644 src/test/ui/generator/type-mismatch-signature-deduction.stderr delete mode 100644 src/test/ui/generator/unresolved-ct-var.rs delete mode 100644 src/test/ui/generator/unresolved-ct-var.stderr delete mode 100644 src/test/ui/generator/xcrate-reachable.rs delete mode 100644 src/test/ui/generator/xcrate.rs delete mode 100644 src/test/ui/generator/yield-in-args-rev.rs delete mode 100644 src/test/ui/generator/yield-in-args-rev.stderr delete mode 100644 src/test/ui/generator/yield-in-args.rs delete mode 100644 src/test/ui/generator/yield-in-args.stderr delete mode 100644 src/test/ui/generator/yield-in-box.rs delete mode 100644 src/test/ui/generator/yield-in-box.stderr delete mode 100644 src/test/ui/generator/yield-in-const.rs delete mode 100644 src/test/ui/generator/yield-in-const.stderr delete mode 100644 src/test/ui/generator/yield-in-function.rs delete mode 100644 src/test/ui/generator/yield-in-function.stderr delete mode 100644 src/test/ui/generator/yield-in-initializer.rs delete mode 100644 src/test/ui/generator/yield-in-initializer.stderr delete mode 100644 src/test/ui/generator/yield-in-static.rs delete mode 100644 src/test/ui/generator/yield-in-static.stderr delete mode 100644 src/test/ui/generator/yield-outside-generator-issue-78653.rs delete mode 100644 src/test/ui/generator/yield-outside-generator-issue-78653.stderr delete mode 100644 src/test/ui/generator/yield-subtype.rs delete mode 100644 src/test/ui/generator/yield-subtype.stderr delete mode 100644 src/test/ui/generator/yield-while-iterating.rs delete mode 100644 src/test/ui/generator/yield-while-iterating.stderr delete mode 100644 src/test/ui/generator/yield-while-local-borrowed.rs delete mode 100644 src/test/ui/generator/yield-while-local-borrowed.stderr delete mode 100644 src/test/ui/generator/yield-while-ref-reborrowed.rs delete mode 100644 src/test/ui/generator/yield-while-ref-reborrowed.stderr delete mode 100644 src/test/ui/generator/yielding-in-match-guards.rs (limited to 'src/test/ui/generator') diff --git a/src/test/ui/generator/addassign-yield.rs b/src/test/ui/generator/addassign-yield.rs deleted file mode 100644 index 66f22bf31..000000000 --- a/src/test/ui/generator/addassign-yield.rs +++ /dev/null @@ -1,35 +0,0 @@ -// run-pass -// Regression test for broken MIR error (#61442) -// Due to the two possible evaluation orders for -// a '+=' expression (depending on whether or not the 'AddAssign' trait -// is being used), we were failing to account for all types that might -// possibly be live across a yield point. - -#![feature(generators)] - -fn foo() { - let _x = static || { - let mut s = String::new(); - s += { yield; "" }; - }; - - let _y = static || { - let x = &mut 0; - *{ yield; x } += match String::new() { _ => 0 }; - }; - - // Please don't ever actually write something like this - let _z = static || { - let x = &mut 0; - *{ - let inner = &mut 1; - *{ yield (); inner } += match String::new() { _ => 1}; - yield; - x - } += match String::new() { _ => 2 }; - }; -} - -fn main() { - foo() -} diff --git a/src/test/ui/generator/async-generator-issue-67158.rs b/src/test/ui/generator/async-generator-issue-67158.rs deleted file mode 100644 index 8125a7a9b..000000000 --- a/src/test/ui/generator/async-generator-issue-67158.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(generators)] -// edition:2018 -// Regression test for #67158. -fn main() { - async { yield print!(":C") }; //~ ERROR `async` generators are not yet supported -} diff --git a/src/test/ui/generator/async-generator-issue-67158.stderr b/src/test/ui/generator/async-generator-issue-67158.stderr deleted file mode 100644 index 7270d188e..000000000 --- a/src/test/ui/generator/async-generator-issue-67158.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0727]: `async` generators are not yet supported - --> $DIR/async-generator-issue-67158.rs:5:13 - | -LL | async { yield print!(":C") }; - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0727`. diff --git a/src/test/ui/generator/auto-trait-regions.rs b/src/test/ui/generator/auto-trait-regions.rs deleted file mode 100644 index ea4b0d554..000000000 --- a/src/test/ui/generator/auto-trait-regions.rs +++ /dev/null @@ -1,53 +0,0 @@ -#![feature(generators)] -#![feature(auto_traits)] -#![feature(negative_impls)] - -auto trait Foo {} - -struct No; - -impl !Foo for No {} - -struct A<'a, 'b>(&'a mut bool, &'b mut bool, No); - -impl<'a, 'b: 'a> Foo for A<'a, 'b> {} - -struct OnlyFooIfStaticRef(No); -impl Foo for &'static OnlyFooIfStaticRef {} - -struct OnlyFooIfRef(No); -impl<'a> Foo for &'a OnlyFooIfRef {} - -fn assert_foo(f: T) {} - -fn main() { - // Make sure 'static is erased for generator interiors so we can't match it in trait selection - let x: &'static _ = &OnlyFooIfStaticRef(No); - let gen = || { - let x = x; - yield; - assert_foo(x); - }; - assert_foo(gen); - //~^ ERROR implementation of `Foo` is not general enough - - // Allow impls which matches any lifetime - let x = &OnlyFooIfRef(No); - let gen = || { - let x = x; - yield; - assert_foo(x); - }; - assert_foo(gen); // ok - - // Disallow impls which relates lifetimes in the generator interior - let gen = || { - let a = A(&mut true, &mut true, No); - //~^ temporary value dropped while borrowed - //~| temporary value dropped while borrowed - yield; - assert_foo(a); - }; - assert_foo(gen); - //~^ ERROR not general enough -} diff --git a/src/test/ui/generator/auto-trait-regions.stderr b/src/test/ui/generator/auto-trait-regions.stderr deleted file mode 100644 index 0b1f34aeb..000000000 --- a/src/test/ui/generator/auto-trait-regions.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:45:24 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/auto-trait-regions.rs:45:35 - | -LL | let a = A(&mut true, &mut true, No); - | ^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary value which is freed while still in use -... -LL | assert_foo(a); - | - borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:31:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... - = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` - -error: implementation of `Foo` is not general enough - --> $DIR/auto-trait-regions.rs:51:5 - | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough - | - = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... - = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/generator/auxiliary/metadata-sufficient-for-layout.rs b/src/test/ui/generator/auxiliary/metadata-sufficient-for-layout.rs deleted file mode 100644 index 207c2735f..000000000 --- a/src/test/ui/generator/auxiliary/metadata-sufficient-for-layout.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: --emit metadata -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::Generator; - -pub fn g() -> impl Generator<(), Yield = (), Return = ()> { - || { - yield; - } -} diff --git a/src/test/ui/generator/auxiliary/xcrate-reachable.rs b/src/test/ui/generator/auxiliary/xcrate-reachable.rs deleted file mode 100644 index 2dd5ea675..000000000 --- a/src/test/ui/generator/auxiliary/xcrate-reachable.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn msg() -> u32 { - 0 -} - -pub fn foo() -> impl Generator<(), Yield=(), Return=u32> { - || { - yield; - return msg(); - } -} diff --git a/src/test/ui/generator/auxiliary/xcrate.rs b/src/test/ui/generator/auxiliary/xcrate.rs deleted file mode 100644 index d07abd091..000000000 --- a/src/test/ui/generator/auxiliary/xcrate.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::Generator; - -pub fn foo() -> impl Generator<(), Yield = (), Return = ()> { - || { - if false { - yield; - } - } -} - -pub fn bar(t: T) -> Box + Unpin> { - Box::new(|| { - yield t; - }) -} diff --git a/src/test/ui/generator/borrow-in-tail-expr.rs b/src/test/ui/generator/borrow-in-tail-expr.rs deleted file mode 100644 index 540f5e3e1..000000000 --- a/src/test/ui/generator/borrow-in-tail-expr.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn main() { - let _a = || { - yield; - let a = String::new(); - a.len() - }; -} diff --git a/src/test/ui/generator/borrowing.rs b/src/test/ui/generator/borrowing.rs deleted file mode 100644 index d36592583..000000000 --- a/src/test/ui/generator/borrowing.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let _b = { - let a = 3; - Pin::new(&mut || yield &a).resume(()) - //~^ ERROR: `a` does not live long enough - }; - - let _b = { - let a = 3; - || { - yield &a - //~^ ERROR: `a` does not live long enough - } - }; -} diff --git a/src/test/ui/generator/borrowing.stderr b/src/test/ui/generator/borrowing.stderr deleted file mode 100644 index 38e1ace8c..000000000 --- a/src/test/ui/generator/borrowing.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:9:33 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | Pin::new(&mut || yield &a).resume(()) - | -- ^ borrowed value does not live long enough - | | - | value captured here by generator -LL | -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:16:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generator/clone-impl-async.rs b/src/test/ui/generator/clone-impl-async.rs deleted file mode 100644 index 9e9b59d36..000000000 --- a/src/test/ui/generator/clone-impl-async.rs +++ /dev/null @@ -1,70 +0,0 @@ -// edition:2021 -// gate-test-generator_clone -// Verifies that feature(generator_clone) doesn't allow async blocks to be cloned/copied. - -#![feature(generators, generator_clone)] - -use std::future::ready; - -struct NonClone; - -fn main() { - let inner_non_clone = async { - let non_clone = NonClone; - let () = ready(()).await; - drop(non_clone); - }; - check_copy(&inner_non_clone); - //~^ ERROR : Copy` is not satisfied - check_clone(&inner_non_clone); - //~^ ERROR : Clone` is not satisfied - - let non_clone = NonClone; - let outer_non_clone = async move { - drop(non_clone); - }; - check_copy(&outer_non_clone); - //~^ ERROR : Copy` is not satisfied - check_clone(&outer_non_clone); - //~^ ERROR : Clone` is not satisfied - - let maybe_copy_clone = async move {}; - check_copy(&maybe_copy_clone); - //~^ ERROR : Copy` is not satisfied - check_clone(&maybe_copy_clone); - //~^ ERROR : Clone` is not satisfied - - let inner_non_clone_fn = the_inner_non_clone_fn(); - check_copy(&inner_non_clone_fn); - //~^ ERROR : Copy` is not satisfied - check_clone(&inner_non_clone_fn); - //~^ ERROR : Clone` is not satisfied - - let outer_non_clone_fn = the_outer_non_clone_fn(NonClone); - check_copy(&outer_non_clone_fn); - //~^ ERROR : Copy` is not satisfied - check_clone(&outer_non_clone_fn); - //~^ ERROR : Clone` is not satisfied - - let maybe_copy_clone_fn = the_maybe_copy_clone_fn(); - check_copy(&maybe_copy_clone_fn); - //~^ ERROR : Copy` is not satisfied - check_clone(&maybe_copy_clone_fn); - //~^ ERROR : Clone` is not satisfied -} - -async fn the_inner_non_clone_fn() { - let non_clone = NonClone; - let () = ready(()).await; - drop(non_clone); -} - -async fn the_outer_non_clone_fn(non_clone: NonClone) { - let () = ready(()).await; - drop(non_clone); -} - -async fn the_maybe_copy_clone_fn() {} - -fn check_copy(_x: &T) {} -fn check_clone(_x: &T) {} diff --git a/src/test/ui/generator/clone-impl-async.stderr b/src/test/ui/generator/clone-impl-async.stderr deleted file mode 100644 index 985472887..000000000 --- a/src/test/ui/generator/clone-impl-async.stderr +++ /dev/null @@ -1,171 +0,0 @@ -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:17:16 - | -LL | check_copy(&inner_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:19:17 - | -LL | check_clone(&inner_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:12:27: 16:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:26:16 - | -LL | check_copy(&outer_non_clone); - | ---------- ^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:28:17 - | -LL | check_clone(&outer_non_clone); - | ----------- ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:23:27: 25:6]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:32:16 - | -LL | check_copy(&maybe_copy_clone); - | ---------- ^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:34:17 - | -LL | check_clone(&maybe_copy_clone); - | ----------- ^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `[async block@$DIR/clone-impl-async.rs:31:28: 31:41]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `impl Future: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:38:16 - | -LL | check_copy(&inner_non_clone_fn); - | ---------- ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `impl Future: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:40:17 - | -LL | check_clone(&inner_non_clone_fn); - | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `impl Future: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:44:16 - | -LL | check_copy(&outer_non_clone_fn); - | ---------- ^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `impl Future: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:46:17 - | -LL | check_clone(&outer_non_clone_fn); - | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error[E0277]: the trait bound `impl Future: Copy` is not satisfied - --> $DIR/clone-impl-async.rs:50:16 - | -LL | check_copy(&maybe_copy_clone_fn); - | ---------- ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `impl Future` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-async.rs:69:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `impl Future: Clone` is not satisfied - --> $DIR/clone-impl-async.rs:52:17 - | -LL | check_clone(&maybe_copy_clone_fn); - | ----------- ^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `impl Future` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-async.rs:70:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/clone-impl-static.rs b/src/test/ui/generator/clone-impl-static.rs deleted file mode 100644 index 55ed0f281..000000000 --- a/src/test/ui/generator/clone-impl-static.rs +++ /dev/null @@ -1,17 +0,0 @@ -// gate-test-generator_clone -// Verifies that static generators cannot be cloned/copied. - -#![feature(generators, generator_clone)] - -fn main() { - let gen = static move || { - yield; - }; - check_copy(&gen); - //~^ ERROR Copy` is not satisfied - check_clone(&gen); - //~^ ERROR Clone` is not satisfied -} - -fn check_copy(_x: &T) {} -fn check_clone(_x: &T) {} diff --git a/src/test/ui/generator/clone-impl-static.stderr b/src/test/ui/generator/clone-impl-static.stderr deleted file mode 100644 index cbadf6f15..000000000 --- a/src/test/ui/generator/clone-impl-static.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0277]: the trait bound `[static generator@$DIR/clone-impl-static.rs:7:15: 7:29]: Copy` is not satisfied - --> $DIR/clone-impl-static.rs:10:16 - | -LL | check_copy(&gen); - | ---------- ^^^^ the trait `Copy` is not implemented for `[static generator@$DIR/clone-impl-static.rs:7:15: 7:29]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_copy` - --> $DIR/clone-impl-static.rs:16:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `[static generator@$DIR/clone-impl-static.rs:7:15: 7:29]: Clone` is not satisfied - --> $DIR/clone-impl-static.rs:12:17 - | -LL | check_clone(&gen); - | ----------- ^^^^ the trait `Clone` is not implemented for `[static generator@$DIR/clone-impl-static.rs:7:15: 7:29]` - | | - | required by a bound introduced by this call - | -note: required by a bound in `check_clone` - --> $DIR/clone-impl-static.rs:17:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/clone-impl.rs b/src/test/ui/generator/clone-impl.rs deleted file mode 100644 index cbfd65a53..000000000 --- a/src/test/ui/generator/clone-impl.rs +++ /dev/null @@ -1,73 +0,0 @@ -// gate-test-generator_clone -// Verifies that non-static generators can be cloned/copied if all their upvars and locals held -// across awaits can be cloned/copied. - -#![feature(generators, generator_clone)] - -struct NonClone; - -fn main() { - let copyable: u32 = 123; - let clonable_0: Vec = Vec::new(); - let clonable_1: Vec = Vec::new(); - let non_clonable: NonClone = NonClone; - - let gen_copy_0 = move || { - yield; - drop(copyable); - }; - check_copy(&gen_copy_0); - check_clone(&gen_copy_0); - let gen_copy_1 = move || { - /* - let v = vec!['a']; - let n = NonClone; - drop(v); - drop(n); - */ - yield; - let v = vec!['a']; - let n = NonClone; - drop(n); - drop(copyable); - }; - check_copy(&gen_copy_1); - check_clone(&gen_copy_1); - let gen_clone_0 = move || { - let v = vec!['a']; - yield; - drop(v); - drop(clonable_0); - }; - check_copy(&gen_clone_0); - //~^ ERROR the trait bound `Vec: Copy` is not satisfied - //~| ERROR the trait bound `Vec: Copy` is not satisfied - check_clone(&gen_clone_0); - let gen_clone_1 = move || { - let v = vec!['a']; - /* - let n = NonClone; - drop(n); - */ - yield; - let n = NonClone; - drop(n); - drop(v); - drop(clonable_1); - }; - check_copy(&gen_clone_1); - //~^ ERROR the trait bound `Vec: Copy` is not satisfied - //~| ERROR the trait bound `Vec: Copy` is not satisfied - check_clone(&gen_clone_1); - let gen_non_clone = move || { - yield; - drop(non_clonable); - }; - check_copy(&gen_non_clone); - //~^ ERROR the trait bound `NonClone: Copy` is not satisfied - check_clone(&gen_non_clone); - //~^ ERROR the trait bound `NonClone: Clone` is not satisfied -} - -fn check_copy(_x: &T) {} -fn check_clone(_x: &T) {} diff --git a/src/test/ui/generator/clone-impl.stderr b/src/test/ui/generator/clone-impl.stderr deleted file mode 100644 index a92646b19..000000000 --- a/src/test/ui/generator/clone-impl.stderr +++ /dev/null @@ -1,142 +0,0 @@ -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `[generator@$DIR/clone-impl.rs:36:23: 36:30]` - --> $DIR/clone-impl.rs:42:16 - | -LL | let gen_clone_0 = move || { - | ------- within this `[generator@$DIR/clone-impl.rs:36:23: 36:30]` -... -LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^^^ within `[generator@$DIR/clone-impl.rs:36:23: 36:30]`, the trait `Copy` is not implemented for `Vec` - | -note: captured value does not implement `Copy` - --> $DIR/clone-impl.rs:40:14 - | -LL | drop(clonable_0); - | ^^^^^^^^^^ has type `Vec` which does not implement `Copy` -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `[generator@$DIR/clone-impl.rs:36:23: 36:30]` - --> $DIR/clone-impl.rs:42:16 - | -LL | let gen_clone_0 = move || { - | ------- within this `[generator@$DIR/clone-impl.rs:36:23: 36:30]` -... -LL | check_copy(&gen_clone_0); - | ^^^^^^^^^^^^ within `[generator@$DIR/clone-impl.rs:36:23: 36:30]`, the trait `Copy` is not implemented for `Vec` - | -note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/clone-impl.rs:38:9 - | -LL | let v = vec!['a']; - | - has type `Vec` which does not implement `Copy` -LL | yield; - | ^^^^^ yield occurs here, with `v` maybe used later -... -LL | }; - | - `v` is later dropped here -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `[generator@$DIR/clone-impl.rs:46:23: 46:30]` - --> $DIR/clone-impl.rs:58:16 - | -LL | let gen_clone_1 = move || { - | ------- within this `[generator@$DIR/clone-impl.rs:46:23: 46:30]` -... -LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^^^ within `[generator@$DIR/clone-impl.rs:46:23: 46:30]`, the trait `Copy` is not implemented for `Vec` - | -note: captured value does not implement `Copy` - --> $DIR/clone-impl.rs:56:14 - | -LL | drop(clonable_1); - | ^^^^^^^^^^ has type `Vec` which does not implement `Copy` -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `Vec: Copy` is not satisfied in `[generator@$DIR/clone-impl.rs:46:23: 46:30]` - --> $DIR/clone-impl.rs:58:16 - | -LL | let gen_clone_1 = move || { - | ------- within this `[generator@$DIR/clone-impl.rs:46:23: 46:30]` -... -LL | check_copy(&gen_clone_1); - | ^^^^^^^^^^^^ within `[generator@$DIR/clone-impl.rs:46:23: 46:30]`, the trait `Copy` is not implemented for `Vec` - | -note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/clone-impl.rs:52:9 - | -LL | let v = vec!['a']; - | - has type `Vec` which does not implement `Copy` -... -LL | yield; - | ^^^^^ yield occurs here, with `v` maybe used later -... -LL | }; - | - `v` is later dropped here -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` - -error[E0277]: the trait bound `NonClone: Copy` is not satisfied in `[generator@$DIR/clone-impl.rs:62:25: 62:32]` - --> $DIR/clone-impl.rs:66:16 - | -LL | let gen_non_clone = move || { - | ------- within this `[generator@$DIR/clone-impl.rs:62:25: 62:32]` -... -LL | check_copy(&gen_non_clone); - | ^^^^^^^^^^^^^^ within `[generator@$DIR/clone-impl.rs:62:25: 62:32]`, the trait `Copy` is not implemented for `NonClone` - | -note: captured value does not implement `Copy` - --> $DIR/clone-impl.rs:64:14 - | -LL | drop(non_clonable); - | ^^^^^^^^^^^^ has type `NonClone` which does not implement `Copy` -note: required by a bound in `check_copy` - --> $DIR/clone-impl.rs:72:18 - | -LL | fn check_copy(_x: &T) {} - | ^^^^ required by this bound in `check_copy` -help: consider annotating `NonClone` with `#[derive(Copy)]` - | -LL | #[derive(Copy)] - | - -error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `[generator@$DIR/clone-impl.rs:62:25: 62:32]` - --> $DIR/clone-impl.rs:68:17 - | -LL | let gen_non_clone = move || { - | ------- within this `[generator@$DIR/clone-impl.rs:62:25: 62:32]` -... -LL | check_clone(&gen_non_clone); - | ^^^^^^^^^^^^^^ within `[generator@$DIR/clone-impl.rs:62:25: 62:32]`, the trait `Clone` is not implemented for `NonClone` - | -note: captured value does not implement `Clone` - --> $DIR/clone-impl.rs:64:14 - | -LL | drop(non_clonable); - | ^^^^^^^^^^^^ has type `NonClone` which does not implement `Clone` -note: required by a bound in `check_clone` - --> $DIR/clone-impl.rs:73:19 - | -LL | fn check_clone(_x: &T) {} - | ^^^^^ required by this bound in `check_clone` -help: consider annotating `NonClone` with `#[derive(Clone)]` - | -LL | #[derive(Clone)] - | - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/conditional-drop.rs b/src/test/ui/generator/conditional-drop.rs deleted file mode 100644 index 0927df869..000000000 --- a/src/test/ui/generator/conditional-drop.rs +++ /dev/null @@ -1,61 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static A: AtomicUsize = AtomicUsize::new(0); - -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); - Pin::new(&mut a).resume(()); - assert_eq!(A.load(Ordering::SeqCst), n + 1); - Pin::new(&mut 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); - Pin::new(&mut a).resume(()); - assert_eq!(A.load(Ordering::SeqCst), n); - Pin::new(&mut a).resume(()); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} diff --git a/src/test/ui/generator/control-flow.rs b/src/test/ui/generator/control-flow.rs deleted file mode 100644 index 4f69c7855..000000000 --- a/src/test/ui/generator/control-flow.rs +++ /dev/null @@ -1,53 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; - -fn finish(mut amt: usize, mut t: T) -> T::Return - where T: Generator<(), Yield = ()> + Unpin, -{ - loop { - match Pin::new(&mut 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/ui/generator/derived-drop-parent-expr.rs b/src/test/ui/generator/derived-drop-parent-expr.rs deleted file mode 100644 index 4bd34346a..000000000 --- a/src/test/ui/generator/derived-drop-parent-expr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// build-pass -// compile-flags:-Zdrop-tracking - -//! Like drop-tracking-parent-expression, but also tests that this doesn't ICE when building MIR -#![feature(generators)] - -fn assert_send(_thing: T) {} - -#[derive(Default)] -pub struct Client { pub nickname: String } - -fn main() { - let g = move || match drop(Client { ..Client::default() }) { - _status => yield, - }; - assert_send(g); -} diff --git a/src/test/ui/generator/discriminant.rs b/src/test/ui/generator/discriminant.rs deleted file mode 100644 index 195e77022..000000000 --- a/src/test/ui/generator/discriminant.rs +++ /dev/null @@ -1,137 +0,0 @@ -//! Tests that generator discriminant sizes and ranges are chosen optimally and that they are -//! reflected in the output of `mem::discriminant`. - -// run-pass - -#![feature(generators, generator_trait, core_intrinsics, discriminant_kind)] - -use std::intrinsics::discriminant_value; -use std::marker::{Unpin, DiscriminantKind}; -use std::mem::size_of_val; -use std::{cmp, ops::*}; - -macro_rules! yield25 { - ($e:expr) => { - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - - yield $e; - yield $e; - yield $e; - yield $e; - yield $e; - }; -} - -/// Yields 250 times. -macro_rules! yield250 { - () => { - yield250!(()) - }; - - ($e:expr) => { - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - yield25!($e); - }; -} - -fn cycle( - gen: impl Generator<()> + Unpin + DiscriminantKind, - expected_max_discr: u32 -) { - let mut gen = Box::pin(gen); - let mut max_discr = 0; - loop { - max_discr = cmp::max(max_discr, discriminant_value(gen.as_mut().get_mut())); - match gen.as_mut().resume(()) { - GeneratorState::Yielded(_) => {} - GeneratorState::Complete(_) => { - assert_eq!(max_discr, expected_max_discr); - return; - } - } - } -} - -fn main() { - // Has only one invalid discr. value. - let gen_u8_tiny_niche = || { - || { - // 3 reserved variants - - yield250!(); // 253 variants - - yield; // 254 - yield; // 255 - } - }; - - // Uses all values in the u8 discriminant. - let gen_u8_full = || { - || { - // 3 reserved variants - - yield250!(); // 253 variants - - yield; // 254 - yield; // 255 - yield; // 256 - } - }; - - // Barely needs a u16 discriminant. - let gen_u16 = || { - || { - // 3 reserved variants - - yield250!(); // 253 variants - - yield; // 254 - yield; // 255 - yield; // 256 - yield; // 257 - } - }; - - assert_eq!(size_of_val(&gen_u8_tiny_niche()), 1); - assert_eq!(size_of_val(&Some(gen_u8_tiny_niche())), 1); // uses niche - assert_eq!(size_of_val(&Some(Some(gen_u8_tiny_niche()))), 2); // cannot use niche anymore - assert_eq!(size_of_val(&gen_u8_full()), 1); - assert_eq!(size_of_val(&Some(gen_u8_full())), 2); // cannot use niche - assert_eq!(size_of_val(&gen_u16()), 2); - assert_eq!(size_of_val(&Some(gen_u16())), 2); // uses niche - - cycle(gen_u8_tiny_niche(), 254); - cycle(gen_u8_full(), 255); - cycle(gen_u16(), 256); -} diff --git a/src/test/ui/generator/drop-and-replace.rs b/src/test/ui/generator/drop-and-replace.rs deleted file mode 100644 index a9a50a122..000000000 --- a/src/test/ui/generator/drop-and-replace.rs +++ /dev/null @@ -1,45 +0,0 @@ -// run-pass -// Regression test for incorrect DropAndReplace behavior introduced in #60840 -// and fixed in #61373. When combined with the optimization implemented in -// #60187, this produced incorrect code for generators when a saved local was -// re-assigned. - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -#[derive(Debug, PartialEq)] -struct Foo(i32); - -impl Drop for Foo { - fn drop(&mut self) { } -} - -fn main() { - let mut a = || { - let mut x = Foo(4); - yield; - assert_eq!(x.0, 4); - - // At one point this tricked our dataflow analysis into thinking `x` was - // StorageDead after the assignment. - x = Foo(5); - assert_eq!(x.0, 5); - - { - let y = Foo(6); - yield; - assert_eq!(y.0, 6); - } - - assert_eq!(x.0, 5); - }; - - loop { - match Pin::new(&mut a).resume(()) { - GeneratorState::Complete(()) => break, - _ => (), - } - } -} diff --git a/src/test/ui/generator/drop-control-flow.rs b/src/test/ui/generator/drop-control-flow.rs deleted file mode 100644 index d38368000..000000000 --- a/src/test/ui/generator/drop-control-flow.rs +++ /dev/null @@ -1,139 +0,0 @@ -// build-pass -// compile-flags: -Zdrop-tracking - -// A test to ensure generators capture values that were conditionally dropped, -// and also that values that are dropped along all paths to a yield do not get -// included in the generator type. - -#![feature(generators, negative_impls)] -#![allow(unused_assignments, dead_code)] - -struct Ptr; -impl<'a> Drop for Ptr { - fn drop(&mut self) {} -} - -struct NonSend; -impl !Send for NonSend {} - -fn assert_send(_: T) {} - -// This test case is reduced from src/test/ui/drop/dynamic-drop-async.rs -fn one_armed_if(arg: bool) { - let _ = || { - let arr = [Ptr]; - if arg { - drop(arr); - } - yield; - }; -} - -fn two_armed_if(arg: bool) { - assert_send(|| { - let arr = [Ptr]; - if arg { - drop(arr); - } else { - drop(arr); - } - yield; - }) -} - -fn if_let(arg: Option) { - let _ = || { - let arr = [Ptr]; - if let Some(_) = arg { - drop(arr); - } - yield; - }; -} - -fn init_in_if(arg: bool) { - assert_send(|| { - let mut x = NonSend; - drop(x); - if arg { - x = NonSend; - } else { - yield; - } - }) -} - -fn init_in_match_arm(arg: Option) { - assert_send(|| { - let mut x = NonSend; - drop(x); - match arg { - Some(_) => x = NonSend, - None => yield, - } - }) -} - -fn reinit() { - let _ = || { - let mut arr = [Ptr]; - drop(arr); - arr = [Ptr]; - yield; - }; -} - -fn loop_uninit() { - let _ = || { - let mut arr = [Ptr]; - let mut count = 0; - drop(arr); - while count < 3 { - yield; - arr = [Ptr]; - count += 1; - } - }; -} - -fn nested_loop() { - let _ = || { - let mut arr = [Ptr]; - let mut count = 0; - drop(arr); - while count < 3 { - for _ in 0..3 { - yield; - } - arr = [Ptr]; - count += 1; - } - }; -} - -fn loop_continue(b: bool) { - let _ = || { - let mut arr = [Ptr]; - let mut count = 0; - drop(arr); - while count < 3 { - count += 1; - yield; - if b { - arr = [Ptr]; - continue; - } - } - }; -} - -fn main() { - one_armed_if(true); - if_let(Some(41)); - init_in_if(true); - init_in_match_arm(Some(41)); - reinit(); - loop_uninit(); - nested_loop(); - loop_continue(true); -} diff --git a/src/test/ui/generator/drop-env.rs b/src/test/ui/generator/drop-env.rs deleted file mode 100644 index 66dfb8c2c..000000000 --- a/src/test/ui/generator/drop-env.rs +++ /dev/null @@ -1,66 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static A: AtomicUsize = AtomicUsize::new(0); - -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(Pin::new(&mut 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(Pin::new(&mut 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/ui/generator/drop-track-addassign-yield.rs b/src/test/ui/generator/drop-track-addassign-yield.rs deleted file mode 100644 index 71cfb170b..000000000 --- a/src/test/ui/generator/drop-track-addassign-yield.rs +++ /dev/null @@ -1,41 +0,0 @@ -// run-pass -// compile-flags: -Zdrop-tracking - -// Based on addassign-yield.rs, but with drop tracking enabled. Originally we did not implement -// the fake_read callback on ExprUseVisitor which caused this case to break. - -#![feature(generators)] - -fn foo() { - let _y = static || { - let x = &mut 0; - *{ - yield; - x - } += match String::new() { - _ => 0, - }; - }; - - // Please don't ever actually write something like this - let _z = static || { - let x = &mut 0; - *{ - let inner = &mut 1; - *{ - yield (); - inner - } += match String::new() { - _ => 1, - }; - yield; - x - } += match String::new() { - _ => 2, - }; - }; -} - -fn main() { - foo() -} diff --git a/src/test/ui/generator/drop-tracking-parent-expression.rs b/src/test/ui/generator/drop-tracking-parent-expression.rs deleted file mode 100644 index d40f1b8f6..000000000 --- a/src/test/ui/generator/drop-tracking-parent-expression.rs +++ /dev/null @@ -1,69 +0,0 @@ -// compile-flags: -Zdrop-tracking -#![feature(generators, negative_impls, rustc_attrs)] - -macro_rules! type_combinations { - ( - $( $name:ident => { $( $tt:tt )* } );* $(;)? - ) => { $( - mod $name { - $( $tt )* - - impl !Sync for Client {} - impl !Send for Client {} - } - - // Struct update syntax. This fails because the Client used in the update is considered - // dropped *after* the yield. - { - let g = move || match drop($name::Client { ..$name::Client::default() }) { - //~^ `significant_drop::Client` which is not `Send` - //~| `insignificant_dtor::Client` which is not `Send` - //~| `derived_drop::Client` which is not `Send` - _ => yield, - }; - assert_send(g); - //~^ ERROR cannot be sent between threads - //~| ERROR cannot be sent between threads - //~| ERROR cannot be sent between threads - } - - // Simple owned value. This works because the Client is considered moved into `drop`, - // even though the temporary expression doesn't end until after the yield. - { - let g = move || match drop($name::Client::default()) { - _ => yield, - }; - assert_send(g); - } - )* } -} - -fn assert_send(_thing: T) {} - -fn main() { - type_combinations!( - // OK - copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; - // NOT OK: MIR borrowck thinks that this is used after the yield, even though - // this has no `Drop` impl and only the drops of the fields are observable. - // FIXME: this should compile. - derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; - // NOT OK - significant_drop => { - #[derive(Default)] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - }; - // NOT OK (we need to agree with MIR borrowck) - insignificant_dtor => { - #[derive(Default)] - #[rustc_insignificant_dtor] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - }; - ); -} diff --git a/src/test/ui/generator/drop-tracking-parent-expression.stderr b/src/test/ui/generator/drop-tracking-parent-expression.stderr deleted file mode 100644 index fbf5d6e07..000000000 --- a/src/test/ui/generator/drop-tracking-parent-expression.stderr +++ /dev/null @@ -1,128 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:24:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28]`, the trait `Send` is not implemented for `derived_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:22:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `derived_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:41:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:24:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28]`, the trait `Send` is not implemented for `significant_drop::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:22:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `significant_drop::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:41:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: generator cannot be sent between threads safely - --> $DIR/drop-tracking-parent-expression.rs:24:25 - | -LL | assert_send(g); - | ^ generator is not `Send` -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation - | - = help: within `[generator@$DIR/drop-tracking-parent-expression.rs:18:21: 18:28]`, the trait `Send` is not implemented for `insignificant_dtor::Client` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-tracking-parent-expression.rs:22:22 - | -LL | let g = move || match drop($name::Client { ..$name::Client::default() }) { - | ------------------------ has type `insignificant_dtor::Client` which is not `Send` -... -LL | _ => yield, - | ^^^^^ yield occurs here, with `$name::Client::default()` maybe used later -LL | }; - | - `$name::Client::default()` is later dropped here -... -LL | / type_combinations!( -LL | | // OK -LL | | copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; -LL | | // NOT OK: MIR borrowck thinks that this is used after the yield, even though -... | -LL | | }; -LL | | ); - | |_____- in this macro invocation -note: required by a bound in `assert_send` - --> $DIR/drop-tracking-parent-expression.rs:41:19 - | -LL | fn assert_send(_thing: T) {} - | ^^^^ required by this bound in `assert_send` - = note: this error originates in the macro `type_combinations` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/generator/drop-tracking-yielding-in-match-guards.rs b/src/test/ui/generator/drop-tracking-yielding-in-match-guards.rs deleted file mode 100644 index 646365e43..000000000 --- a/src/test/ui/generator/drop-tracking-yielding-in-match-guards.rs +++ /dev/null @@ -1,12 +0,0 @@ -// build-pass -// edition:2018 -// compile-flags: -Zdrop-tracking - -#![feature(generators)] - -fn main() { - let _ = static |x: u8| match x { - y if { yield } == y + 1 => (), - _ => (), - }; -} diff --git a/src/test/ui/generator/drop-yield-twice.rs b/src/test/ui/generator/drop-yield-twice.rs deleted file mode 100644 index f484cbb8d..000000000 --- a/src/test/ui/generator/drop-yield-twice.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(negative_impls, generators)] - -struct Foo(i32); -impl !Send for Foo {} - -fn main() { - assert_send(|| { //~ ERROR generator cannot be sent between threads safely - let guard = Foo(42); - yield; - drop(guard); - yield; - }) -} - -fn assert_send(_: T) {} diff --git a/src/test/ui/generator/drop-yield-twice.stderr b/src/test/ui/generator/drop-yield-twice.stderr deleted file mode 100644 index 0808a2c85..000000000 --- a/src/test/ui/generator/drop-yield-twice.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/drop-yield-twice.rs:7:17 - | -LL | assert_send(|| { - | _________________^ -LL | | let guard = Foo(42); -LL | | yield; -LL | | drop(guard); -LL | | yield; -LL | | }) - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/drop-yield-twice.rs:7:17: 7:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/drop-yield-twice.rs:9:9 - | -LL | let guard = Foo(42); - | ----- has type `Foo` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -... -LL | }) - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/drop-yield-twice.rs:15:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to previous error - diff --git a/src/test/ui/generator/dropck-resume.rs b/src/test/ui/generator/dropck-resume.rs deleted file mode 100644 index 4c18077f3..000000000 --- a/src/test/ui/generator/dropck-resume.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -struct SetToNone<'a: 'b, 'b>(&'b mut Option<&'a i32>); - -impl<'a, 'b> Drop for SetToNone<'a, 'b> { - fn drop(&mut self) { - *self.0 = None; - } -} - -fn drop_using_generator() -> i32 { - let mut y = Some(&0); - let z = &mut y; - let r; - { - let mut g = move |r| { - let _s = SetToNone(r); - yield; - }; - let mut g = Pin::new(&mut g); - g.as_mut().resume(z); - r = y.as_ref().unwrap(); - //~^ ERROR cannot borrow `y` as immutable because it is also borrowed as mutable - } - **r -} - -fn main() { - println!("{}", drop_using_generator()); -} diff --git a/src/test/ui/generator/dropck-resume.stderr b/src/test/ui/generator/dropck-resume.stderr deleted file mode 100644 index b0756eb55..000000000 --- a/src/test/ui/generator/dropck-resume.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/dropck-resume.rs:25:13 - | -LL | let z = &mut y; - | ------ mutable borrow occurs here -... -LL | r = y.as_ref().unwrap(); - | ^^^^^^^^^^ immutable borrow occurs here -LL | -LL | } - | - mutable borrow might be used here, when `g` is dropped and runs the destructor for generator - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/generator/dropck.rs b/src/test/ui/generator/dropck.rs deleted file mode 100644 index f82111a76..000000000 --- a/src/test/ui/generator/dropck.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::cell::RefCell; -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let (mut gen, cell); - cell = Box::new(RefCell::new(0)); - let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); - //~^ ERROR `*cell` does not live long enough [E0597] - // the upvar is the non-dropck `&mut Option>`. - gen = || { - // but the generator can use it to drop a `Ref<'a, i32>`. - let _d = ref_.take(); //~ ERROR `ref_` does not live long enough - yield; - }; - Pin::new(&mut gen).resume(()); - // drops the RefCell and then the Ref, leading to use-after-free -} diff --git a/src/test/ui/generator/dropck.stderr b/src/test/ui/generator/dropck.stderr deleted file mode 100644 index 7bb188352..000000000 --- a/src/test/ui/generator/dropck.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0597]: `*cell` does not live long enough - --> $DIR/dropck.rs:10:40 - | -LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); - | ^^^^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `*cell` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `ref_` does not live long enough - --> $DIR/dropck.rs:15:18 - | -LL | gen = || { - | -- value captured here by generator -LL | // but the generator can use it to drop a `Ref<'a, i32>`. -LL | let _d = ref_.take(); - | ^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `ref_` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generator/generator-region-requirements.migrate.stderr b/src/test/ui/generator/generator-region-requirements.migrate.stderr deleted file mode 100644 index 8a96d187f..000000000 --- a/src/test/ui/generator/generator-region-requirements.migrate.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/generator-region-requirements.rs:16:51 - | -LL | fn dangle(x: &mut i32) -> &'static mut i32 { - | -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32` -... -LL | GeneratorState::Complete(c) => return c, - | ^ lifetime `'static` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/generator/generator-region-requirements.rs b/src/test/ui/generator/generator-region-requirements.rs deleted file mode 100644 index 7269a79ca..000000000 --- a/src/test/ui/generator/generator-region-requirements.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(generators, generator_trait)] -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -fn dangle(x: &mut i32) -> &'static mut i32 { - let mut g = || { - yield; - x - }; - loop { - match Pin::new(&mut g).resume(()) { - GeneratorState::Complete(c) => return c, - //~^ ERROR lifetime may not live long enough - GeneratorState::Yielded(_) => (), - } - } -} - -fn main() {} diff --git a/src/test/ui/generator/generator-region-requirements.stderr b/src/test/ui/generator/generator-region-requirements.stderr deleted file mode 100644 index 87f604672..000000000 --- a/src/test/ui/generator/generator-region-requirements.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/generator-region-requirements.rs:12:51 - | -LL | fn dangle(x: &mut i32) -> &'static mut i32 { - | - let's call the lifetime of this reference `'1` -... -LL | GeneratorState::Complete(c) => return c, - | ^ returning this value requires that `'1` must outlive `'static` - -error: aborting due to previous error - diff --git a/src/test/ui/generator/generator-resume-after-panic.rs b/src/test/ui/generator/generator-resume-after-panic.rs deleted file mode 100644 index f2e67f1f7..000000000 --- a/src/test/ui/generator/generator-resume-after-panic.rs +++ /dev/null @@ -1,25 +0,0 @@ -// run-fail -// needs-unwind -// error-pattern:generator resumed after panicking -// ignore-emscripten no processes - -// Test that we get the correct message for resuming a panicked generator. - -#![feature(generators, generator_trait)] - -use std::{ - ops::Generator, - pin::Pin, - panic, -}; - -fn main() { - let mut g = || { - panic!(); - yield; - }; - panic::catch_unwind(panic::AssertUnwindSafe(|| { - let x = Pin::new(&mut g).resume(()); - })); - Pin::new(&mut g).resume(()); -} diff --git a/src/test/ui/generator/generator-with-nll.rs b/src/test/ui/generator/generator-with-nll.rs deleted file mode 100644 index cee3e6d22..000000000 --- a/src/test/ui/generator/generator-with-nll.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(generators)] - -fn main() { - || { - // The reference in `_a` is a Legal with NLL since it ends before the yield - let _a = &mut true; - let b = &mut true; - //~^ borrow may still be in use when generator yields - yield (); - println!("{}", b); - }; -} diff --git a/src/test/ui/generator/generator-with-nll.stderr b/src/test/ui/generator/generator-with-nll.stderr deleted file mode 100644 index 14199aeb9..000000000 --- a/src/test/ui/generator/generator-with-nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/generator-with-nll.rs:7:17 - | -LL | let b = &mut true; - | ^^^^^^^^^ -LL | -LL | yield (); - | -------- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/generator/generator-yielding-or-returning-itself.rs b/src/test/ui/generator/generator-yielding-or-returning-itself.rs deleted file mode 100644 index 30788e3c1..000000000 --- a/src/test/ui/generator/generator-yielding-or-returning-itself.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![feature(generator_trait)] -#![feature(generators)] - -// Test that we cannot create a generator that returns a value of its -// own type. - -use std::ops::Generator; - -pub fn want_cyclic_generator_return(_: T) - where T: Generator -{ -} - -fn supply_cyclic_generator_return() { - want_cyclic_generator_return(|| { - //~^ ERROR type mismatch - if false { yield None.unwrap(); } - None.unwrap() - }) -} - -pub fn want_cyclic_generator_yield(_: T) - where T: Generator -{ -} - -fn supply_cyclic_generator_yield() { - want_cyclic_generator_yield(|| { - //~^ ERROR type mismatch - if false { yield None.unwrap(); } - None.unwrap() - }) -} - -fn main() { } diff --git a/src/test/ui/generator/generator-yielding-or-returning-itself.stderr b/src/test/ui/generator/generator-yielding-or-returning-itself.stderr deleted file mode 100644 index 8f5d2429a..000000000 --- a/src/test/ui/generator/generator-yielding-or-returning-itself.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36] as Generator>::Return == [generator@$DIR/generator-yielding-or-returning-itself.rs:15:34: 15:36]` - --> $DIR/generator-yielding-or-returning-itself.rs:15:34 - | -LL | want_cyclic_generator_return(|| { - | _____----------------------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | if false { yield None.unwrap(); } -LL | | None.unwrap() -LL | | }) - | |_____^ cyclic type of infinite size - | - = note: closures cannot capture themselves or take themselves as argument; - this error may be the result of a recent compiler bug-fix, - see issue #46062 - for more information -note: required by a bound in `want_cyclic_generator_return` - --> $DIR/generator-yielding-or-returning-itself.rs:10:36 - | -LL | pub fn want_cyclic_generator_return(_: T) - | ---------------------------- required by a bound in this -LL | where T: Generator - | ^^^^^^^^^^ required by this bound in `want_cyclic_generator_return` - -error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35] as Generator>::Yield == [generator@$DIR/generator-yielding-or-returning-itself.rs:28:33: 28:35]` - --> $DIR/generator-yielding-or-returning-itself.rs:28:33 - | -LL | want_cyclic_generator_yield(|| { - | _____---------------------------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | if false { yield None.unwrap(); } -LL | | None.unwrap() -LL | | }) - | |_____^ cyclic type of infinite size - | - = note: closures cannot capture themselves or take themselves as argument; - this error may be the result of a recent compiler bug-fix, - see issue #46062 - for more information -note: required by a bound in `want_cyclic_generator_yield` - --> $DIR/generator-yielding-or-returning-itself.rs:23:24 - | -LL | pub fn want_cyclic_generator_yield(_: T) - | --------------------------- required by a bound in this -LL | where T: Generator - | ^^^^^^^^^ required by this bound in `want_cyclic_generator_yield` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/generator/issue-102645.rs b/src/test/ui/generator/issue-102645.rs deleted file mode 100644 index 0589c5a00..000000000 --- a/src/test/ui/generator/issue-102645.rs +++ /dev/null @@ -1,23 +0,0 @@ -// compile-flags: -Zdrop-tracking - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let mut a = 5; - let mut b = || { - let d = 6; - yield; - _zzz(); // #break - a = d; - }; - Pin::new(&mut b).resume(); - //~^ ERROR this function takes 1 argument but 0 arguments were supplied - // This type error is required to reproduce the ICE... -} - -fn _zzz() { - () -} diff --git a/src/test/ui/generator/issue-102645.stderr b/src/test/ui/generator/issue-102645.stderr deleted file mode 100644 index 7b4d50213..000000000 --- a/src/test/ui/generator/issue-102645.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0061]: this function takes 1 argument but 0 arguments were supplied - --> $DIR/issue-102645.rs:16:22 - | -LL | Pin::new(&mut b).resume(); - | ^^^^^^-- an argument of type `()` is missing - | -note: associated function defined here - --> $SRC_DIR/core/src/ops/generator.rs:LL:COL - | -LL | fn resume(self: Pin<&mut Self>, arg: R) -> GeneratorState; - | ^^^^^^ -help: provide the argument - | -LL | Pin::new(&mut b).resume(()); - | ~~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0061`. diff --git a/src/test/ui/generator/issue-44197.rs b/src/test/ui/generator/issue-44197.rs deleted file mode 100644 index 389b9d139..000000000 --- a/src/test/ui/generator/issue-44197.rs +++ /dev/null @@ -1,36 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -fn foo(_: &str) -> String { - String::new() -} - -fn bar(baz: String) -> impl Generator<(), Yield = String, Return = ()> { - move || { - yield foo(&baz); - } -} - -fn foo2(_: &str) -> Result { - Err(()) -} - -fn bar2(baz: String) -> impl Generator<(), Yield = String, Return = ()> { - move || { - if let Ok(quux) = foo2(&baz) { - yield quux; - } - } -} - -fn main() { - assert_eq!( - Pin::new(&mut bar(String::new())).resume(()), - GeneratorState::Yielded(String::new()) - ); - assert_eq!(Pin::new(&mut bar2(String::new())).resume(()), GeneratorState::Complete(())); -} diff --git a/src/test/ui/generator/issue-45729-unsafe-in-generator.mir.stderr b/src/test/ui/generator/issue-45729-unsafe-in-generator.mir.stderr deleted file mode 100644 index 3afbea079..000000000 --- a/src/test/ui/generator/issue-45729-unsafe-in-generator.mir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-45729-unsafe-in-generator.rs:8:9 - | -LL | *(1 as *mut u32) = 42; - | ^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer - | - = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/generator/issue-45729-unsafe-in-generator.rs b/src/test/ui/generator/issue-45729-unsafe-in-generator.rs deleted file mode 100644 index 379c36d2c..000000000 --- a/src/test/ui/generator/issue-45729-unsafe-in-generator.rs +++ /dev/null @@ -1,12 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck - -#![feature(generators)] - -fn main() { - let _ = || { - *(1 as *mut u32) = 42; - //~^ ERROR dereference of raw pointer is unsafe - yield; - }; -} diff --git a/src/test/ui/generator/issue-45729-unsafe-in-generator.thir.stderr b/src/test/ui/generator/issue-45729-unsafe-in-generator.thir.stderr deleted file mode 100644 index 10d768f19..000000000 --- a/src/test/ui/generator/issue-45729-unsafe-in-generator.thir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/issue-45729-unsafe-in-generator.rs:8:9 - | -LL | *(1 as *mut u32) = 42; - | ^^^^^^^^^^^^^^^^ dereference of raw pointer - | - = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/generator/issue-48048.rs b/src/test/ui/generator/issue-48048.rs deleted file mode 100644 index 992bbc97a..000000000 --- a/src/test/ui/generator/issue-48048.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(generators)] - -fn main() { - let x = (|_| {},); - - || { - let x = x; - - x.0({ //~ ERROR borrow may still be in use when generator yields - yield; - }); - }; -} diff --git a/src/test/ui/generator/issue-48048.stderr b/src/test/ui/generator/issue-48048.stderr deleted file mode 100644 index 234235839..000000000 --- a/src/test/ui/generator/issue-48048.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/issue-48048.rs:9:9 - | -LL | x.0({ - | ^^^ -LL | yield; - | ----- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/generator/issue-52304.rs b/src/test/ui/generator/issue-52304.rs deleted file mode 100644 index 3e9de765b..000000000 --- a/src/test/ui/generator/issue-52304.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -pub fn example() -> impl Generator { - || yield &1 -} - -fn main() {} diff --git a/src/test/ui/generator/issue-52398.rs b/src/test/ui/generator/issue-52398.rs deleted file mode 100644 index ada380d11..000000000 --- a/src/test/ui/generator/issue-52398.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -#![allow(unused_variables)] - -#![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 || { //~ WARN unused generator that must be used - 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 || { //~ WARN unused generator that must be used - yield *y.borrow(); - return "Done"; - }; -} diff --git a/src/test/ui/generator/issue-52398.stderr b/src/test/ui/generator/issue-52398.stderr deleted file mode 100644 index 539343275..000000000 --- a/src/test/ui/generator/issue-52398.stderr +++ /dev/null @@ -1,24 +0,0 @@ -warning: unused generator that must be used - --> $DIR/issue-52398.rs:17:5 - | -LL | / move || { -LL | | A.test(yield); -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: unused generator that must be used - --> $DIR/issue-52398.rs:24:5 - | -LL | / static move || { -LL | | yield *y.borrow(); -LL | | return "Done"; -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - -warning: 2 warnings emitted - diff --git a/src/test/ui/generator/issue-53548-1.rs b/src/test/ui/generator/issue-53548-1.rs deleted file mode 100644 index 173ae3c6f..000000000 --- a/src/test/ui/generator/issue-53548-1.rs +++ /dev/null @@ -1,20 +0,0 @@ -// A variant of #53548 that does not actually require generators, -// but which encountered the same ICE/error. See `issue-53548.rs` -// for details. -// -// check-pass - -use std::cell::RefCell; -use std::rc::Rc; - -trait Trait: 'static {} - -struct Store { - inner: Rc>>, -} - -fn main() { - let store = Store:: fn(&(dyn Trait + 'a))>> { - inner: Default::default(), - }; -} diff --git a/src/test/ui/generator/issue-53548.rs b/src/test/ui/generator/issue-53548.rs deleted file mode 100644 index 3ebabb914..000000000 --- a/src/test/ui/generator/issue-53548.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Regression test for #53548. The `Box` type below is -// expanded to `Box`, but the generator "witness" -// that results is `for<'r> { Box }`. The WF code was -// encountering an ICE (when debug-assertions were enabled) and an -// unexpected compilation error (without debug-asserions) when trying -// to process this `'r` region bound. In particular, to be WF, the -// region bound must meet the requirements of the trait, and hence we -// got `for<'r> { 'r: 'static }`. This would ICE because the `Binder` -// constructor we were using was assering that no higher-ranked -// regions were involved (because the WF code is supposed to skip -// those). The error (if debug-asserions were disabled) came because -// we obviously cannot prove that `'r: 'static` for any region `'r`. -// Pursuant with our "lazy WF" strategy for higher-ranked regions, the -// fix is not to require that `for<'r> { 'r: 'static }` holds (this is -// also analogous to what we would do for higher-ranked regions -// appearing within the trait in other positions). -// -// check-pass - -#![feature(generators)] - -use std::cell::RefCell; -use std::rc::Rc; - -trait Trait: 'static {} - -struct Store { - inner: Rc>>, -} - -fn main() { - Box::new(static move || { - let store = Store::> { - inner: Default::default(), - }; - yield (); - }); -} diff --git a/src/test/ui/generator/issue-57017.rs b/src/test/ui/generator/issue-57017.rs deleted file mode 100644 index c0bde3b44..000000000 --- a/src/test/ui/generator/issue-57017.rs +++ /dev/null @@ -1,55 +0,0 @@ -// build-pass -// compile-flags: -Zdrop-tracking -#![feature(generators, negative_impls)] - -macro_rules! type_combinations { - ( - $( $name:ident => { $( $tt:tt )* } );* - ) => { $( - mod $name { - pub mod unsync { - $( $tt )* - - impl !Sync for Client {} - } - pub mod unsend { - $( $tt )* - - impl !Send for Client {} - } - } - - // This is the same bug as issue 57017, but using yield instead of await - { - let g = move || match drop(&$name::unsync::Client::default()) { - _status => yield, - }; - assert_send(g); - } - - // This tests that `Client` is properly considered to be dropped after moving it into the - // function. - { - let g = move || match drop($name::unsend::Client::default()) { - _status => yield, - }; - assert_send(g); - } - )* } -} - -fn assert_send(_thing: T) {} - -fn main() { - type_combinations!( - copy => { #[derive(Copy, Clone, Default)] pub struct Client; }; - derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } }; - significant_drop => { - #[derive(Default)] - pub struct Client; - impl Drop for Client { - fn drop(&mut self) {} - } - } - ); -} diff --git a/src/test/ui/generator/issue-57084.rs b/src/test/ui/generator/issue-57084.rs deleted file mode 100644 index 2a5c3dd05..000000000 --- a/src/test/ui/generator/issue-57084.rs +++ /dev/null @@ -1,28 +0,0 @@ -// This issue reproduces an ICE on compile (E.g. fails on 2018-12-19 nightly). -// "cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(1)) <= '_#1r" -// run-pass -// edition:2018 -#![feature(generators,generator_trait)] -use std::ops::Generator; - -fn with(f: F) -> impl Generator -where F: Fn() -> () -{ - move || { - loop { - match f() { - _ => yield, - } - } - } -} - -fn main() { - let data = &vec![1]; - || { //~ WARN unused generator that must be used - let _to_pin = with(move || println!("{:p}", data)); - loop { - yield - } - }; -} diff --git a/src/test/ui/generator/issue-57084.stderr b/src/test/ui/generator/issue-57084.stderr deleted file mode 100644 index 8f1fc5e80..000000000 --- a/src/test/ui/generator/issue-57084.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning: unused generator that must be used - --> $DIR/issue-57084.rs:22:5 - | -LL | / || { -LL | | let _to_pin = with(move || println!("{:p}", data)); -LL | | loop { -LL | | yield -LL | | } -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/issue-57478.rs b/src/test/ui/generator/issue-57478.rs deleted file mode 100644 index 91407ea18..000000000 --- a/src/test/ui/generator/issue-57478.rs +++ /dev/null @@ -1,17 +0,0 @@ -// check-pass -// compile-flags: -Zdrop-tracking - -#![feature(negative_impls, generators)] - -struct Foo; -impl !Send for Foo {} - -fn main() { - assert_send(|| { - let guard = Foo; - drop(guard); - yield; - }) -} - -fn assert_send(_: T) {} diff --git a/src/test/ui/generator/issue-58888.rs b/src/test/ui/generator/issue-58888.rs deleted file mode 100644 index d42d09d40..000000000 --- a/src/test/ui/generator/issue-58888.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -// compile-flags: -g -// ignore-asmjs wasm2js does not support source maps yet - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -struct Database; - -impl Database { - fn get_connection(&self) -> impl Iterator { - Some(()).into_iter() - } - - fn check_connection(&self) -> impl Generator + '_ { - move || { - let iter = self.get_connection(); - for i in iter { - yield i - } - } - } -} - -fn main() { - Database.check_connection(); -} diff --git a/src/test/ui/generator/issue-61442-stmt-expr-with-drop.rs b/src/test/ui/generator/issue-61442-stmt-expr-with-drop.rs deleted file mode 100644 index 187c37402..000000000 --- a/src/test/ui/generator/issue-61442-stmt-expr-with-drop.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Test that we don't consider temporaries for statement expressions as live -// across yields - -// check-pass -// edition:2018 - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -async fn drop_and_await() { - async {}; - async {}.await; -} - -fn drop_and_yield() { - let x = || { - String::new(); - yield; - }; - Box::pin(x).as_mut().resume(()); - let y = static || { - String::new(); - yield; - }; - Box::pin(y).as_mut().resume(()); -} - -fn main() { - drop_and_await(); - drop_and_yield(); -} diff --git a/src/test/ui/generator/issue-62506-two_awaits.rs b/src/test/ui/generator/issue-62506-two_awaits.rs deleted file mode 100644 index 672e16b78..000000000 --- a/src/test/ui/generator/issue-62506-two_awaits.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Output = String caused an ICE whereas Output = &'static str compiled successfully. -// Broken MIR: generator contains type std::string::String in MIR, -// but typeck only knows about {::Future, ()} -// check-pass -// edition:2018 - -use std::future::Future; - -pub trait T { - type Future: Future; - fn bar() -> Self::Future; -} -pub async fn foo() where S: T { - S::bar().await; - S::bar().await; -} -pub fn main() {} diff --git a/src/test/ui/generator/issue-64620-yield-array-element.rs b/src/test/ui/generator/issue-64620-yield-array-element.rs deleted file mode 100644 index 2cbe8f516..000000000 --- a/src/test/ui/generator/issue-64620-yield-array-element.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Regression test for #64620 - -#![feature(generators)] - -pub fn crash(arr: [usize; 1]) { - yield arr[0]; //~ ERROR: yield expression outside of generator literal -} - -fn main() {} diff --git a/src/test/ui/generator/issue-64620-yield-array-element.stderr b/src/test/ui/generator/issue-64620-yield-array-element.stderr deleted file mode 100644 index 48383c2ed..000000000 --- a/src/test/ui/generator/issue-64620-yield-array-element.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/issue-64620-yield-array-element.rs:6:5 - | -LL | yield arr[0]; - | ^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/src/test/ui/generator/issue-68112.rs b/src/test/ui/generator/issue-68112.rs deleted file mode 100644 index 21026f45c..000000000 --- a/src/test/ui/generator/issue-68112.rs +++ /dev/null @@ -1,71 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::{ - cell::RefCell, - sync::Arc, - pin::Pin, - ops::{Generator, GeneratorState}, -}; - -pub struct Ready(Option); -impl Generator<()> for Ready { - type Return = T; - type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) - } -} -pub fn make_gen1(t: T) -> Ready { - Ready(Some(t)) -} - -fn require_send(_: impl Send) {} -//~^ NOTE required by a bound -//~| NOTE required by a bound -//~| NOTE required by this bound -//~| NOTE required by this bound - -fn make_non_send_generator() -> impl Generator>> { - make_gen1(Arc::new(RefCell::new(0))) -} - -fn test1() { - let send_gen = || { - let _non_send_gen = make_non_send_generator(); - //~^ NOTE not `Send` - yield; - //~^ NOTE yield occurs here - //~| NOTE value is used across a yield - }; //~ NOTE later dropped here - require_send(send_gen); - //~^ ERROR generator cannot be sent between threads - //~| NOTE not `Send` -} - -pub fn make_gen2(t: T) -> impl Generator { -//~^ NOTE appears within the type -//~| NOTE expansion of desugaring - || { //~ NOTE used within this generator - yield; - t - } -} -fn make_non_send_generator2() -> impl Generator>> { //~ NOTE appears within the type -//~^ NOTE expansion of desugaring - make_gen2(Arc::new(RefCell::new(0))) -} - -fn test2() { - let send_gen = || { //~ NOTE used within this generator - let _non_send_gen = make_non_send_generator2(); - yield; - }; - require_send(send_gen); - //~^ ERROR `RefCell` cannot be shared between threads safely - //~| NOTE `RefCell` cannot be shared between threads safely - //~| NOTE required for - //~| NOTE required by a bound introduced by this call - //~| NOTE captures the following types -} - -fn main() {} diff --git a/src/test/ui/generator/issue-68112.stderr b/src/test/ui/generator/issue-68112.stderr deleted file mode 100644 index eb99d42c9..000000000 --- a/src/test/ui/generator/issue-68112.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/issue-68112.rs:40:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` -note: generator is not `Send` as this value is used across a yield - --> $DIR/issue-68112.rs:36:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `impl Generator>>` which is not `Send` -LL | -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -... -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:22:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/issue-68112.rs:63:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:48:5 - | -LL | || { - | ^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:45:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `impl Generator>>` - --> $DIR/issue-68112.rs:53:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `impl Generator>>`, `()` -note: required because it's used within this generator - --> $DIR/issue-68112.rs:59:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/issue-68112.rs:22:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/issue-69017.rs b/src/test/ui/generator/issue-69017.rs deleted file mode 100644 index 511deb60e..000000000 --- a/src/test/ui/generator/issue-69017.rs +++ /dev/null @@ -1,18 +0,0 @@ -// This issue reproduces an ICE on compile -// Fails on 2020-02-08 nightly -// regressed commit: https://github.com/rust-lang/rust/commit/f8fd4624474a68bd26694eff3536b9f3a127b2d3 -// -// check-pass - -#![feature(generator_trait)] -#![feature(generators)] - -use std::ops::Generator; - -fn gen() -> impl Generator { - |_: usize| { - println!("-> {}", yield); - } -} - -fn main() {} diff --git a/src/test/ui/generator/issue-69039.rs b/src/test/ui/generator/issue-69039.rs deleted file mode 100644 index ccc141860..000000000 --- a/src/test/ui/generator/issue-69039.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; - -fn mkstr(my_name: String, my_mood: String) -> String { - format!("{} is {}", my_name.trim(), my_mood.trim()) -} - -fn my_scenario() -> impl Generator { - |_arg: String| { - let my_name = yield "What is your name?"; - let my_mood = yield "How are you feeling?"; - mkstr(my_name, my_mood) - } -} - -fn main() { - let mut my_session = Box::pin(my_scenario()); - - assert_eq!( - my_session.as_mut().resume("_arg".to_string()), - GeneratorState::Yielded("What is your name?") - ); - assert_eq!( - my_session.as_mut().resume("Your Name".to_string()), - GeneratorState::Yielded("How are you feeling?") - ); - assert_eq!( - my_session.as_mut().resume("Sensory Organs".to_string()), - GeneratorState::Complete("Your Name is Sensory Organs".to_string()) - ); -} diff --git a/src/test/ui/generator/issue-87142.rs b/src/test/ui/generator/issue-87142.rs deleted file mode 100644 index fc10d04d4..000000000 --- a/src/test/ui/generator/issue-87142.rs +++ /dev/null @@ -1,32 +0,0 @@ -// compile-flags: -Cdebuginfo=2 -// build-pass - -// Regression test for #87142 -// This test needs the above flags and the "lib" crate type. - -#![feature(type_alias_impl_trait, generator_trait, generators)] -#![crate_type = "lib"] - -use std::ops::Generator; - -pub trait GeneratorProviderAlt: Sized { - type Gen: Generator<(), Return = (), Yield = ()>; - - fn start(ctx: Context) -> Self::Gen; -} - -pub struct Context { - pub link: Box, -} - -impl GeneratorProviderAlt for () { - type Gen = impl Generator<(), Return = (), Yield = ()>; - fn start(ctx: Context) -> Self::Gen { - move || { - match ctx { - _ => (), - } - yield (); - } - } -} diff --git a/src/test/ui/generator/issue-88653.rs b/src/test/ui/generator/issue-88653.rs deleted file mode 100644 index 1d9377bce..000000000 --- a/src/test/ui/generator/issue-88653.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Regression test for #88653, where a confusing warning about a -// type mismatch in generator arguments was issued. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn foo(bar: bool) -> impl Generator<(bool,)> { - //~^ ERROR: type mismatch in generator arguments [E0631] - //~| NOTE: expected due to this - //~| NOTE: expected generator signature `fn((bool,)) -> _` - //~| NOTE: in this expansion of desugaring of `impl Trait` - //~| NOTE: in this expansion of desugaring of `impl Trait` - |bar| { - //~^ NOTE: found signature defined here - if bar { - yield bar; - } - } -} - -fn main() {} diff --git a/src/test/ui/generator/issue-88653.stderr b/src/test/ui/generator/issue-88653.stderr deleted file mode 100644 index b742c6e2f..000000000 --- a/src/test/ui/generator/issue-88653.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0631]: type mismatch in generator arguments - --> $DIR/issue-88653.rs:8:22 - | -LL | fn foo(bar: bool) -> impl Generator<(bool,)> { - | ^^^^^^^^^^^^^^^^^^^^^^^ expected due to this -... -LL | |bar| { - | ----- found signature defined here - | - = note: expected generator signature `fn((bool,)) -> _` - found generator signature `fn(bool) -> _` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/generator/issue-91477.rs b/src/test/ui/generator/issue-91477.rs deleted file mode 100644 index 6c027feb4..000000000 --- a/src/test/ui/generator/issue-91477.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(generators)] - -fn foo() -> impl Sized { - yield 1; //~ ERROR E0627 -} - -fn main() {} diff --git a/src/test/ui/generator/issue-91477.stderr b/src/test/ui/generator/issue-91477.stderr deleted file mode 100644 index 4597dc1bc..000000000 --- a/src/test/ui/generator/issue-91477.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/issue-91477.rs:4:5 - | -LL | yield 1; - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/src/test/ui/generator/issue-93161.rs b/src/test/ui/generator/issue-93161.rs deleted file mode 100644 index 92305609c..000000000 --- a/src/test/ui/generator/issue-93161.rs +++ /dev/null @@ -1,94 +0,0 @@ -// edition:2021 -// run-pass -// compile-flags: -Zdrop-tracking - -#![feature(never_type)] - -use std::future::Future; - -// See if we can run a basic `async fn` -pub async fn foo(x: &u32, y: u32) -> u32 { - let y = &y; - let z = 9; - let z = &z; - let y = async { *y + *z }.await; - let a = 10; - let a = &a; - *x + y + *a -} - -async fn add(x: u32, y: u32) -> u32 { - let a = async { x + y }; - a.await -} - -async fn build_aggregate(a: u32, b: u32, c: u32, d: u32) -> u32 { - let x = (add(a, b).await, add(c, d).await); - x.0 + x.1 -} - -enum Never {} -fn never() -> Never { - panic!() -} - -async fn includes_never(crash: bool, x: u32) -> u32 { - let result = async { x * x }.await; - if !crash { - return result; - } - #[allow(unused)] - let bad = never(); - result *= async { x + x }.await; - drop(bad); - result -} - -async fn partial_init(x: u32) -> u32 { - #[allow(unreachable_code)] - let _x: (String, !) = (String::new(), return async { x + x }.await); -} - -async fn read_exact(_from: &mut &[u8], _to: &mut [u8]) -> Option<()> { - Some(()) -} - -async fn hello_world() { - let data = [0u8; 1]; - let mut reader = &data[..]; - - let mut marker = [0u8; 1]; - read_exact(&mut reader, &mut marker).await.unwrap(); -} - -fn run_fut(fut: impl Future) -> T { - use std::sync::Arc; - use std::task::{Context, Poll, Wake, Waker}; - - struct MyWaker; - impl Wake for MyWaker { - fn wake(self: Arc) { - unimplemented!() - } - } - - let waker = Waker::from(Arc::new(MyWaker)); - let mut context = Context::from_waker(&waker); - - let mut pinned = Box::pin(fut); - loop { - match pinned.as_mut().poll(&mut context) { - Poll::Pending => continue, - Poll::Ready(v) => return v, - } - } -} - -fn main() { - let x = 5; - assert_eq!(run_fut(foo(&x, 7)), 31); - assert_eq!(run_fut(build_aggregate(1, 2, 3, 4)), 10); - assert_eq!(run_fut(includes_never(false, 4)), 16); - assert_eq!(run_fut(partial_init(4)), 8); - run_fut(hello_world()); -} diff --git a/src/test/ui/generator/iterator-count.rs b/src/test/ui/generator/iterator-count.rs deleted file mode 100644 index 90eefe02f..000000000 --- a/src/test/ui/generator/iterator-count.rs +++ /dev/null @@ -1,44 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; - -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 + Unpin> Iterator for W { - type Item = T::Yield; - - fn next(&mut self) -> Option { - match Pin::new(&mut self.0).resume(()) { - GeneratorState::Complete(..) => None, - GeneratorState::Yielded(v) => Some(v), - } - } -} - -fn test() -> impl Generator<(), Return=(), Yield=u8> + Unpin { - || { - 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/ui/generator/layout-error.rs b/src/test/ui/generator/layout-error.rs deleted file mode 100644 index 7c3d18740..000000000 --- a/src/test/ui/generator/layout-error.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Verifies that computing a layout of a generator tainted by type errors -// doesn't ICE. Regression test for #80998. -// -// edition:2018 - -#![feature(type_alias_impl_trait)] -use std::future::Future; - -pub struct Task(F); -impl Task { - const fn new() -> Self { - todo!() - } - fn spawn(&self, _: impl FnOnce() -> F) { - todo!() - } -} - -fn main() { - async fn cb() { - let a = Foo; //~ ERROR cannot find value `Foo` in this scope - } - - type F = impl Future; - // Check that statics are inhabited computes they layout. - static POOL: Task = Task::new(); - Task::spawn(&POOL, || cb()); -} diff --git a/src/test/ui/generator/layout-error.stderr b/src/test/ui/generator/layout-error.stderr deleted file mode 100644 index b1a258f4f..000000000 --- a/src/test/ui/generator/layout-error.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0425]: cannot find value `Foo` in this scope - --> $DIR/layout-error.rs:21:17 - | -LL | let a = Foo; - | ^^^ not found in this scope - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/generator/live-upvar-across-yield.rs b/src/test/ui/generator/live-upvar-across-yield.rs deleted file mode 100644 index 6a2e42a55..000000000 --- a/src/test/ui/generator/live-upvar-across-yield.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let b = |_| 3; - let mut a = || { - b(yield); - }; - Pin::new(&mut a).resume(()); -} diff --git a/src/test/ui/generator/match-bindings.rs b/src/test/ui/generator/match-bindings.rs deleted file mode 100644 index 865904a57..000000000 --- a/src/test/ui/generator/match-bindings.rs +++ /dev/null @@ -1,23 +0,0 @@ -// run-pass -#![allow(dead_code)] - -#![feature(generators)] - -enum Enum { - A(String), - B -} - -fn main() { - || { //~ WARN unused generator that must be used - loop { - if let true = true { - match Enum::A(String::new()) { - Enum::A(_var) => {} - Enum::B => {} - } - } - yield; - } - }; -} diff --git a/src/test/ui/generator/match-bindings.stderr b/src/test/ui/generator/match-bindings.stderr deleted file mode 100644 index 3dd2d5954..000000000 --- a/src/test/ui/generator/match-bindings.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/match-bindings.rs:12:5 - | -LL | / || { -LL | | loop { -LL | | if let true = true { -LL | | match Enum::A(String::new()) { -... | -LL | | } -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/metadata-sufficient-for-layout.rs b/src/test/ui/generator/metadata-sufficient-for-layout.rs deleted file mode 100644 index d0e648ee7..000000000 --- a/src/test/ui/generator/metadata-sufficient-for-layout.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Check that the layout of a generator is available when auxiliary crate -// is compiled with --emit metadata. -// -// Regression test for #80998. -// -// aux-build:metadata-sufficient-for-layout.rs - -#![feature(type_alias_impl_trait, rustc_attrs)] -#![feature(generator_trait)] - -extern crate metadata_sufficient_for_layout; - -use std::ops::Generator; - -type F = impl Generator<(), Yield = (), Return = ()>; - -// Static queries the layout of the generator. -static A: Option = None; - -fn f() -> F { - metadata_sufficient_for_layout::g() -} - -#[rustc_error] -fn main() {} //~ ERROR diff --git a/src/test/ui/generator/metadata-sufficient-for-layout.stderr b/src/test/ui/generator/metadata-sufficient-for-layout.stderr deleted file mode 100644 index 3488b04f2..000000000 --- a/src/test/ui/generator/metadata-sufficient-for-layout.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/metadata-sufficient-for-layout.rs:25:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/generator/nested_generators.rs b/src/test/ui/generator/nested_generators.rs deleted file mode 100644 index 45519150e..000000000 --- a/src/test/ui/generator/nested_generators.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; - -fn main() { - let _generator = || { - let mut sub_generator = || { - yield 2; - }; - - match Pin::new(&mut sub_generator).resume(()) { - GeneratorState::Yielded(x) => { - yield x; - } - _ => panic!(), - }; - }; -} diff --git a/src/test/ui/generator/niche-in-generator.rs b/src/test/ui/generator/niche-in-generator.rs deleted file mode 100644 index 42bee81f5..000000000 --- a/src/test/ui/generator/niche-in-generator.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Test that niche finding works with captured generator upvars. - -// run-pass - -#![feature(generators)] - -use std::mem::size_of_val; - -fn take(_: T) {} - -fn main() { - let x = false; - let gen1 = || { - yield; - take(x); - }; - - assert_eq!(size_of_val(&gen1), size_of_val(&Some(gen1))); -} diff --git a/src/test/ui/generator/non-static-is-unpin.rs b/src/test/ui/generator/non-static-is-unpin.rs deleted file mode 100644 index 96d0a8e28..000000000 --- a/src/test/ui/generator/non-static-is-unpin.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::marker::{PhantomPinned, Unpin}; - -fn assert_unpin(_: G) { -} - -fn main() { - // Even though this generator holds a `PhantomPinned` in its environment, it - // remains `Unpin`. - assert_unpin(|| { - let pinned = PhantomPinned; - yield; - drop(pinned); - }); -} diff --git a/src/test/ui/generator/not-send-sync.rs b/src/test/ui/generator/not-send-sync.rs deleted file mode 100644 index 8ca5565fb..000000000 --- a/src/test/ui/generator/not-send-sync.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(generators)] - -use std::cell::Cell; - -fn main() { - fn assert_sync(_: T) {} - fn assert_send(_: T) {} - - assert_sync(|| { - //~^ ERROR: generator cannot be shared between threads safely - let a = Cell::new(2); - yield; - }); - - let a = Cell::new(2); - assert_send(|| { - //~^ ERROR: E0277 - drop(&a); - yield; - }); -} diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr deleted file mode 100644 index a821c57b9..000000000 --- a/src/test/ui/generator/not-send-sync.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/not-send-sync.rs:16:17 - | -LL | assert_send(|| { - | _____-----------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | drop(&a); -LL | | yield; -LL | | }); - | |_____^ `Cell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Cell` - = note: required for `&Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/not-send-sync.rs:16:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/not-send-sync.rs:7:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be shared between threads safely - --> $DIR/not-send-sync.rs:9:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[generator@$DIR/not-send-sync.rs:9:17: 9:19]`, the trait `Sync` is not implemented for `Cell` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/not-send-sync.rs:12:9 - | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/not-send-sync.rs:6:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/overlap-locals.rs b/src/test/ui/generator/overlap-locals.rs deleted file mode 100644 index 101c8714f..000000000 --- a/src/test/ui/generator/overlap-locals.rs +++ /dev/null @@ -1,29 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn main() { - let a = || { - { - let w: i32 = 4; - yield; - println!("{:?}", w); - } - { - let x: i32 = 5; - yield; - println!("{:?}", x); - } - { - let y: i32 = 6; - yield; - println!("{:?}", y); - } - { - let z: i32 = 7; - yield; - println!("{:?}", z); - } - }; - assert_eq!(8, std::mem::size_of_val(&a)); -} diff --git a/src/test/ui/generator/panic-drops-resume.rs b/src/test/ui/generator/panic-drops-resume.rs deleted file mode 100644 index 4c3caeb14..000000000 --- a/src/test/ui/generator/panic-drops-resume.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! Tests that panics inside a generator will correctly drop the initial resume argument. - -// run-pass -// needs-unwind - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic::{catch_unwind, AssertUnwindSafe}; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static DROP: AtomicUsize = AtomicUsize::new(0); - -struct Dropper {} - -impl Drop for Dropper { - fn drop(&mut self) { - DROP.fetch_add(1, Ordering::SeqCst); - } -} - -fn main() { - let mut gen = |_arg| { - if true { - panic!(); - } - yield (); - }; - let mut gen = Pin::new(&mut gen); - - assert_eq!(DROP.load(Ordering::Acquire), 0); - let res = catch_unwind(AssertUnwindSafe(|| gen.as_mut().resume(Dropper {}))); - assert!(res.is_err()); - assert_eq!(DROP.load(Ordering::Acquire), 1); -} diff --git a/src/test/ui/generator/panic-drops.rs b/src/test/ui/generator/panic-drops.rs deleted file mode 100644 index 65001fd87..000000000 --- a/src/test/ui/generator/panic-drops.rs +++ /dev/null @@ -1,57 +0,0 @@ -// run-pass -// needs-unwind - - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static A: AtomicUsize = AtomicUsize::new(0); - -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(|| { - Pin::new(&mut 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(|| { - Pin::new(&mut foo).resume(()) - })); - assert!(res.is_err()); - assert_eq!(A.load(Ordering::SeqCst), 1); -} diff --git a/src/test/ui/generator/panic-safe.rs b/src/test/ui/generator/panic-safe.rs deleted file mode 100644 index 3db80bb58..000000000 --- a/src/test/ui/generator/panic-safe.rs +++ /dev/null @@ -1,30 +0,0 @@ -// run-pass -// needs-unwind - - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; -use std::panic; - -fn main() { - let mut foo = || { - if true { - panic!(); - } - yield; - }; - - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - Pin::new(&mut foo).resume(()) - })); - assert!(res.is_err()); - - for _ in 0..10 { - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - Pin::new(&mut foo).resume(()) - })); - assert!(res.is_err()); - } -} diff --git a/src/test/ui/generator/partial-drop.rs b/src/test/ui/generator/partial-drop.rs deleted file mode 100644 index c872fb7f3..000000000 --- a/src/test/ui/generator/partial-drop.rs +++ /dev/null @@ -1,42 +0,0 @@ -// compile-flags: -Zdrop-tracking - -#![feature(negative_impls, generators)] - -struct Foo; -impl !Send for Foo {} - -struct Bar { - foo: Foo, - x: i32, -} - -fn main() { - assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. - let guard = Bar { foo: Foo, x: 42 }; - drop(guard.foo); - yield; - }); - - assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. - let guard = Bar { foo: Foo, x: 42 }; - drop(guard); - guard.foo = Foo; - guard.x = 23; - yield; - }); - - assert_send(|| { - //~^ ERROR generator cannot be sent between threads safely - // FIXME: it would be nice to make this work. - let guard = Bar { foo: Foo, x: 42 }; - let Bar { foo, x } = guard; - drop(foo); - yield; - }); -} - -fn assert_send(_: T) {} diff --git a/src/test/ui/generator/partial-drop.stderr b/src/test/ui/generator/partial-drop.stderr deleted file mode 100644 index 9baafe54e..000000000 --- a/src/test/ui/generator/partial-drop.stderr +++ /dev/null @@ -1,92 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:14:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -LL | | drop(guard.foo); -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:14:17: 14:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:19:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -LL | drop(guard.foo); -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:22:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -... | -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:22:17: 22:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:29:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -... -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be sent between threads safely - --> $DIR/partial-drop.rs:32:17 - | -LL | assert_send(|| { - | _________________^ -LL | | -LL | | // FIXME: it would be nice to make this work. -LL | | let guard = Bar { foo: Foo, x: 42 }; -... | -LL | | yield; -LL | | }); - | |_____^ generator is not `Send` - | - = help: within `[generator@$DIR/partial-drop.rs:32:17: 32:19]`, the trait `Send` is not implemented for `Foo` -note: generator is not `Send` as this value is used across a yield - --> $DIR/partial-drop.rs:38:9 - | -LL | let guard = Bar { foo: Foo, x: 42 }; - | ----- has type `Bar` which is not `Send` -... -LL | yield; - | ^^^^^ yield occurs here, with `guard` maybe used later -LL | }); - | - `guard` is later dropped here -note: required by a bound in `assert_send` - --> $DIR/partial-drop.rs:42:19 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/generator/partial-initialization-across-yield.rs b/src/test/ui/generator/partial-initialization-across-yield.rs deleted file mode 100644 index 65d9e6d39..000000000 --- a/src/test/ui/generator/partial-initialization-across-yield.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Test that we don't allow yielding from a generator while a local is partially -// initialized. - -#![feature(generators)] - -struct S { x: i32, y: i32 } -struct T(i32, i32); - -fn test_tuple() { - let _ = || { - let mut t: (i32, i32); - t.0 = 42; //~ ERROR E0381 - yield; - t.1 = 88; - let _ = t; - }; -} - -fn test_tuple_struct() { - let _ = || { - let mut t: T; - t.0 = 42; //~ ERROR E0381 - yield; - t.1 = 88; - let _ = t; - }; -} - -fn test_struct() { - let _ = || { - let mut t: S; - t.x = 42; //~ ERROR E0381 - yield; - t.y = 88; - let _ = t; - }; -} - -fn main() { - test_tuple(); - test_tuple_struct(); - test_struct(); -} diff --git a/src/test/ui/generator/partial-initialization-across-yield.stderr b/src/test/ui/generator/partial-initialization-across-yield.stderr deleted file mode 100644 index 3f9f1c046..000000000 --- a/src/test/ui/generator/partial-initialization-across-yield.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0381]: partially assigned binding `t` isn't fully initialized - --> $DIR/partial-initialization-across-yield.rs:12:9 - | -LL | let mut t: (i32, i32); - | ----- binding declared here but left uninitialized -LL | t.0 = 42; - | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized - | - = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit` - -error[E0381]: partially assigned binding `t` isn't fully initialized - --> $DIR/partial-initialization-across-yield.rs:22:9 - | -LL | let mut t: T; - | ----- binding declared here but left uninitialized -LL | t.0 = 42; - | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized - | - = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit` - -error[E0381]: partially assigned binding `t` isn't fully initialized - --> $DIR/partial-initialization-across-yield.rs:32:9 - | -LL | let mut t: S; - | ----- binding declared here but left uninitialized -LL | t.x = 42; - | ^^^^^^^^ `t` partially assigned here but it isn't fully initialized - | - = help: partial initialization isn't supported, fully initialize the binding with a default value and mutate it, or use `std::mem::MaybeUninit` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/generator/pattern-borrow.rs b/src/test/ui/generator/pattern-borrow.rs deleted file mode 100644 index d19363708..000000000 --- a/src/test/ui/generator/pattern-borrow.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(generators)] - -enum Test { A(i32), B, } - -fn main() { } - -fn fun(test: Test) { - move || { - if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields - yield (); - _a.use_ref(); - } - }; -} - -trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } } -impl Fake for T { } diff --git a/src/test/ui/generator/pattern-borrow.stderr b/src/test/ui/generator/pattern-borrow.stderr deleted file mode 100644 index d78da5104..000000000 --- a/src/test/ui/generator/pattern-borrow.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/pattern-borrow.rs:9:24 - | -LL | if let Test::A(ref _a) = test { - | ^^^^^^ -LL | yield (); - | -------- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/generator/pin-box-generator.rs b/src/test/ui/generator/pin-box-generator.rs deleted file mode 100644 index c3136f5c0..000000000 --- a/src/test/ui/generator/pin-box-generator.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn assert_generator(_: G) { -} - -fn main() { - assert_generator(static || yield); - assert_generator(Box::pin(static || yield)); -} diff --git a/src/test/ui/generator/print/generator-print-verbose-1.rs b/src/test/ui/generator/print/generator-print-verbose-1.rs deleted file mode 100644 index fe0687722..000000000 --- a/src/test/ui/generator/print/generator-print-verbose-1.rs +++ /dev/null @@ -1,60 +0,0 @@ -// compile-flags: -Zverbose - -// Same as: src/test/ui/generator/issue-68112.stderr - -#![feature(generators, generator_trait)] - -use std::{ - cell::RefCell, - sync::Arc, - pin::Pin, - ops::{Generator, GeneratorState}, -}; - -pub struct Ready(Option); -impl Generator<()> for Ready { - type Return = T; - type Yield = (); - fn resume(mut self: Pin<&mut Self>, _args: ()) -> GeneratorState<(), T> { - GeneratorState::Complete(self.0.take().unwrap()) - } -} -pub fn make_gen1(t: T) -> Ready { - Ready(Some(t)) -} - -fn require_send(_: impl Send) {} - -fn make_non_send_generator() -> impl Generator>> { - make_gen1(Arc::new(RefCell::new(0))) -} - -fn test1() { - let send_gen = || { - let _non_send_gen = make_non_send_generator(); - yield; - }; - require_send(send_gen); - //~^ ERROR generator cannot be sent between threads -} - -pub fn make_gen2(t: T) -> impl Generator { - || { - yield; - t - } -} -fn make_non_send_generator2() -> impl Generator>> { - make_gen2(Arc::new(RefCell::new(0))) -} - -fn test2() { - let send_gen = || { - let _non_send_gen = make_non_send_generator2(); - yield; - }; - require_send(send_gen); - //~^ ERROR `RefCell` cannot be shared between threads safely -} - -fn main() {} diff --git a/src/test/ui/generator/print/generator-print-verbose-1.stderr b/src/test/ui/generator/print/generator-print-verbose-1.stderr deleted file mode 100644 index ed0628bbb..000000000 --- a/src/test/ui/generator/print/generator-print-verbose-1.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error: generator cannot be sent between threads safely - --> $DIR/generator-print-verbose-1.rs:37:18 - | -LL | require_send(send_gen); - | ^^^^^^^^ generator is not `Send` - | - = help: the trait `Sync` is not implemented for `RefCell` -note: generator is not `Send` as this value is used across a yield - --> $DIR/generator-print-verbose-1.rs:35:9 - | -LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send` -LL | yield; - | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later -LL | }; - | - `_non_send_gen` is later dropped here -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:26:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error[E0277]: `RefCell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-1.rs:56:18 - | -LL | require_send(send_gen); - | ------------ ^^^^^^^^ `RefCell` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `RefCell` - = note: required for `Arc>` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:42:5 - | -LL | || { - | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc>])` - --> $DIR/generator-print-verbose-1.rs:41:30 - | -LL | pub fn make_gen2(t: T) -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` - --> $DIR/generator-print-verbose-1.rs:47:34 - | -LL | fn make_non_send_generator2() -> impl Generator>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-1.rs:52:20 - | -LL | let send_gen = || { - | ^^ -note: required by a bound in `require_send` - --> $DIR/generator-print-verbose-1.rs:26:25 - | -LL | fn require_send(_: impl Send) {} - | ^^^^ required by this bound in `require_send` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/print/generator-print-verbose-2.rs b/src/test/ui/generator/print/generator-print-verbose-2.rs deleted file mode 100644 index d914719cb..000000000 --- a/src/test/ui/generator/print/generator-print-verbose-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// compile-flags: -Zverbose - -// Same as test/ui/generator/not-send-sync.rs -#![feature(generators)] - -use std::cell::Cell; - -fn main() { - fn assert_sync(_: T) {} - fn assert_send(_: T) {} - - assert_sync(|| { - //~^ ERROR: generator cannot be shared between threads safely - let a = Cell::new(2); - yield; - }); - - let a = Cell::new(2); - assert_send(|| { - //~^ ERROR: E0277 - drop(&a); - yield; - }); -} diff --git a/src/test/ui/generator/print/generator-print-verbose-2.stderr b/src/test/ui/generator/print/generator-print-verbose-2.stderr deleted file mode 100644 index 909e49c38..000000000 --- a/src/test/ui/generator/print/generator-print-verbose-2.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error[E0277]: `Cell` cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:19:17 - | -LL | assert_send(|| { - | _____-----------_^ - | | | - | | required by a bound introduced by this call -LL | | -LL | | drop(&a); -LL | | yield; -LL | | }); - | |_____^ `Cell` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Cell` - = note: required for `&'_#4r Cell` to implement `Send` -note: required because it's used within this generator - --> $DIR/generator-print-verbose-2.rs:19:17 - | -LL | assert_send(|| { - | ^^ -note: required by a bound in `assert_send` - --> $DIR/generator-print-verbose-2.rs:10:23 - | -LL | fn assert_send(_: T) {} - | ^^^^ required by this bound in `assert_send` - -error: generator cannot be shared between threads safely - --> $DIR/generator-print-verbose-2.rs:12:17 - | -LL | assert_sync(|| { - | _________________^ -LL | | -LL | | let a = Cell::new(2); -LL | | yield; -LL | | }); - | |_____^ generator is not `Sync` - | - = help: within `[main::{closure#0} upvar_tys=() {Cell, ()}]`, the trait `Sync` is not implemented for `Cell` -note: generator is not `Sync` as this value is used across a yield - --> $DIR/generator-print-verbose-2.rs:15:9 - | -LL | let a = Cell::new(2); - | - has type `Cell` which is not `Sync` -LL | yield; - | ^^^^^ yield occurs here, with `a` maybe used later -LL | }); - | - `a` is later dropped here -note: required by a bound in `assert_sync` - --> $DIR/generator-print-verbose-2.rs:9:23 - | -LL | fn assert_sync(_: T) {} - | ^^^^ required by this bound in `assert_sync` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/print/generator-print-verbose-3.rs b/src/test/ui/generator/print/generator-print-verbose-3.rs deleted file mode 100644 index 8689539ec..000000000 --- a/src/test/ui/generator/print/generator-print-verbose-3.rs +++ /dev/null @@ -1,12 +0,0 @@ -// compile-flags: -Zverbose - -#![feature(generators, generator_trait)] - -fn main() { - let x = "Type mismatch test"; - let generator :() = || { - //~^ ERROR mismatched types - yield 1i32; - return x - }; -} diff --git a/src/test/ui/generator/print/generator-print-verbose-3.stderr b/src/test/ui/generator/print/generator-print-verbose-3.stderr deleted file mode 100644 index d15646259..000000000 --- a/src/test/ui/generator/print/generator-print-verbose-3.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/generator-print-verbose-3.rs:7:25 - | -LL | let generator :() = || { - | ____________________--___^ - | | | - | | expected due to this -LL | | -LL | | yield 1i32; -LL | | return x -LL | | }; - | |_____^ expected `()`, found generator - | - = note: expected unit type `()` - found generator `[main::{closure#0} upvar_tys=(unavailable)]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/generator/reborrow-mut-upvar.rs b/src/test/ui/generator/reborrow-mut-upvar.rs deleted file mode 100644 index dbd9e24e2..000000000 --- a/src/test/ui/generator/reborrow-mut-upvar.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn _run(bar: &mut i32) { - || { //~ WARN unused generator that must be used - { - let _baz = &*bar; - yield; - } - - *bar = 2; - }; -} - -fn main() {} diff --git a/src/test/ui/generator/reborrow-mut-upvar.stderr b/src/test/ui/generator/reborrow-mut-upvar.stderr deleted file mode 100644 index 2e1fec35e..000000000 --- a/src/test/ui/generator/reborrow-mut-upvar.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/reborrow-mut-upvar.rs:6:5 - | -LL | / || { -LL | | { -LL | | let _baz = &*bar; -LL | | yield; -... | -LL | | *bar = 2; -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.rs b/src/test/ui/generator/ref-escapes-but-not-over-yield.rs deleted file mode 100644 index 3856d8233..000000000 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(generators)] - -fn foo(x: &i32) { - // In this case, a reference to `b` escapes the generator, but not - // because of a yield. We see that there is no yield in the scope of - // `b` and give the more generic error message. - let mut a = &3; - let mut b = move || { - yield(); - let b = 5; - a = &b; - //~^ ERROR borrowed data escapes outside of generator - }; -} - -fn main() { } diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr b/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr deleted file mode 100644 index 5fc810040..000000000 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0521]: borrowed data escapes outside of generator - --> $DIR/ref-escapes-but-not-over-yield.rs:11:9 - | -LL | let mut a = &3; - | ----- `a` declared here, outside of the generator body -... -LL | a = &b; - | ^^^^-- - | | | - | | borrow is only valid in the generator body - | reference to `b` escapes the generator body here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generator/reinit-in-match-guard.rs b/src/test/ui/generator/reinit-in-match-guard.rs deleted file mode 100644 index 260b341a5..000000000 --- a/src/test/ui/generator/reinit-in-match-guard.rs +++ /dev/null @@ -1,25 +0,0 @@ -// build-pass - -#![feature(generators)] - -#![allow(unused_assignments, dead_code)] - -fn main() { - let _ = || { - let mut x = vec![22_usize]; - std::mem::drop(x); - match y() { - true if { - x = vec![]; - false - } => {} - _ => { - yield; - } - } - }; -} - -fn y() -> bool { - true -} diff --git a/src/test/ui/generator/resume-after-return.rs b/src/test/ui/generator/resume-after-return.rs deleted file mode 100644 index 01a059a16..000000000 --- a/src/test/ui/generator/resume-after-return.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -// needs-unwind - - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; -use std::panic; - -fn main() { - let mut foo = || { - if true { - return - } - yield; - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - match panic::catch_unwind(move || Pin::new(&mut foo).resume(())) { - Ok(_) => panic!("generator successfully resumed"), - Err(_) => {} - } -} diff --git a/src/test/ui/generator/resume-arg-late-bound.rs b/src/test/ui/generator/resume-arg-late-bound.rs deleted file mode 100644 index 1c35ba80d..000000000 --- a/src/test/ui/generator/resume-arg-late-bound.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Tests that we cannot produce a generator that accepts a resume argument -//! with any lifetime and then stores it across a `yield`. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn test(a: impl for<'a> Generator<&'a mut bool>) {} - -fn main() { - let gen = |arg: &mut bool| { - yield (); - *arg = true; - }; - test(gen); - //~^ ERROR mismatched types -} diff --git a/src/test/ui/generator/resume-arg-late-bound.stderr b/src/test/ui/generator/resume-arg-late-bound.stderr deleted file mode 100644 index 34ee4036c..000000000 --- a/src/test/ui/generator/resume-arg-late-bound.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/resume-arg-late-bound.rs:15:5 - | -LL | test(gen); - | ^^^^^^^^^ one type is more general than the other - | - = note: expected trait `for<'a> Generator<&'a mut bool>` - found trait `Generator<&mut bool>` -note: the lifetime requirement is introduced here - --> $DIR/resume-arg-late-bound.rs:8:17 - | -LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/generator/resume-arg-size.rs b/src/test/ui/generator/resume-arg-size.rs deleted file mode 100644 index b93dc54f7..000000000 --- a/src/test/ui/generator/resume-arg-size.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![feature(generators)] - -// run-pass - -use std::mem::size_of_val; - -fn main() { - // Generator taking a `Copy`able resume arg. - let gen_copy = |mut x: usize| { - loop { - drop(x); - x = yield; - } - }; - - // Generator taking a non-`Copy` resume arg. - let gen_move = |mut x: Box| { - loop { - drop(x); - x = yield; - } - }; - - // Neither of these generators have the resume arg live across the `yield`, so they should be - // 1 Byte in size (only storing the discriminant) - assert_eq!(size_of_val(&gen_copy), 1); - assert_eq!(size_of_val(&gen_move), 1); -} diff --git a/src/test/ui/generator/resume-live-across-yield.rs b/src/test/ui/generator/resume-live-across-yield.rs deleted file mode 100644 index 4c4cf117a..000000000 --- a/src/test/ui/generator/resume-live-across-yield.rs +++ /dev/null @@ -1,45 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static DROP: AtomicUsize = AtomicUsize::new(0); - -#[derive(PartialEq, Eq, Debug)] -struct Dropper(String); - -impl Drop for Dropper { - fn drop(&mut self) { - DROP.fetch_add(1, Ordering::SeqCst); - } -} - -fn main() { - let mut g = |mut _d| { - _d = yield; - _d - }; - - let mut g = Pin::new(&mut g); - - assert_eq!( - g.as_mut().resume(Dropper(String::from("Hello world!"))), - GeneratorState::Yielded(()) - ); - assert_eq!(DROP.load(Ordering::Acquire), 0); - match g.as_mut().resume(Dropper(String::from("Number Two"))) { - GeneratorState::Complete(dropper) => { - assert_eq!(DROP.load(Ordering::Acquire), 1); - assert_eq!(dropper.0, "Number Two"); - drop(dropper); - assert_eq!(DROP.load(Ordering::Acquire), 2); - } - _ => unreachable!(), - } - - drop(g); - assert_eq!(DROP.load(Ordering::Acquire), 2); -} diff --git a/src/test/ui/generator/retain-resume-ref.rs b/src/test/ui/generator/retain-resume-ref.rs deleted file mode 100644 index 0606ea71c..000000000 --- a/src/test/ui/generator/retain-resume-ref.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! This test ensures that a mutable reference cannot be passed as a resume argument twice. - -#![feature(generators, generator_trait)] - -use std::marker::Unpin; -use std::ops::{ - Generator, - GeneratorState::{self, *}, -}; -use std::pin::Pin; - -fn main() { - let mut thing = String::from("hello"); - - let mut gen = |r| { - if false { - yield r; - } - }; - - let mut gen = Pin::new(&mut gen); - gen.as_mut().resume(&mut thing); - gen.as_mut().resume(&mut thing); - //~^ cannot borrow `thing` as mutable more than once at a time -} diff --git a/src/test/ui/generator/retain-resume-ref.stderr b/src/test/ui/generator/retain-resume-ref.stderr deleted file mode 100644 index e33310d12..000000000 --- a/src/test/ui/generator/retain-resume-ref.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `thing` as mutable more than once at a time - --> $DIR/retain-resume-ref.rs:23:25 - | -LL | gen.as_mut().resume(&mut thing); - | ---------- first mutable borrow occurs here -LL | gen.as_mut().resume(&mut thing); - | ------ ^^^^^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/generator/size-moved-locals.rs b/src/test/ui/generator/size-moved-locals.rs deleted file mode 100644 index 601a31418..000000000 --- a/src/test/ui/generator/size-moved-locals.rs +++ /dev/null @@ -1,78 +0,0 @@ -// run-pass -// Test that we don't duplicate storage for a variable that is moved to another -// binding. This used to happen in the presence of unwind and drop edges (see -// `complex` below.) -// -// The exact sizes here can change (we'd like to know when they do). What we -// don't want to see is the `complex` generator size being upwards of 2048 bytes -// (which would indicate it is reserving space for two copies of Foo.) -// -// See issue #59123 for a full explanation. - -// edition:2018 -// ignore-wasm32 issue #62807 -// ignore-asmjs issue #62807 -// needs-unwind Size of Closures change on panic=abort - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -const FOO_SIZE: usize = 1024; -struct Foo(#[allow(unused_tuple_struct_fields)] [u8; FOO_SIZE]); - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn move_before_yield() -> impl Generator { - static || { - let first = Foo([0; FOO_SIZE]); - let _second = first; - yield; - // _second dropped here - } -} - -fn noop() {} - -fn move_before_yield_with_noop() -> impl Generator { - static || { - let first = Foo([0; FOO_SIZE]); - noop(); - let _second = first; - yield; - // _second dropped here - } -} - -// Today we don't have NRVO (we allocate space for both `first` and `second`,) -// but we can overlap `first` with `_third`. -fn overlap_move_points() -> impl Generator { - static || { - let first = Foo([0; FOO_SIZE]); - yield; - let second = first; - yield; - let _third = second; - yield; - } -} - -fn overlap_x_and_y() -> impl Generator { - static || { - let x = Foo([0; FOO_SIZE]); - yield; - drop(x); - let y = Foo([0; FOO_SIZE]); - yield; - drop(y); - } -} - -fn main() { - assert_eq!(1025, std::mem::size_of_val(&move_before_yield())); - assert_eq!(1026, std::mem::size_of_val(&move_before_yield_with_noop())); - assert_eq!(2051, std::mem::size_of_val(&overlap_move_points())); - assert_eq!(1026, std::mem::size_of_val(&overlap_x_and_y())); -} diff --git a/src/test/ui/generator/sized-yield.rs b/src/test/ui/generator/sized-yield.rs deleted file mode 100644 index c6dd738d6..000000000 --- a/src/test/ui/generator/sized-yield.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - let s = String::from("foo"); - let mut gen = move || { - //~^ ERROR the size for values of type - yield s[..]; - }; - Pin::new(&mut gen).resume(()); - //~^ ERROR the size for values of type -} diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr deleted file mode 100644 index ea2a48d13..000000000 --- a/src/test/ui/generator/sized-yield.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/sized-yield.rs:8:26 - | -LL | let mut gen = move || { - | __________________________^ -LL | | -LL | | yield s[..]; -LL | | }; - | |____^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` - = note: the yield type of a generator must have a statically known size - -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/sized-yield.rs:12:23 - | -LL | Pin::new(&mut gen).resume(()); - | ^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` -note: required by a bound in `GeneratorState` - --> $SRC_DIR/core/src/ops/generator.rs:LL:COL - | -LL | pub enum GeneratorState { - | ^ required by this bound in `GeneratorState` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/smoke-resume-args.rs b/src/test/ui/generator/smoke-resume-args.rs deleted file mode 100644 index fa9271c53..000000000 --- a/src/test/ui/generator/smoke-resume-args.rs +++ /dev/null @@ -1,100 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -#![feature(generators, generator_trait)] - -use std::fmt::Debug; -use std::marker::Unpin; -use std::ops::{ - Generator, - GeneratorState::{self, *}, -}; -use std::pin::Pin; -use std::sync::atomic::{AtomicUsize, Ordering}; - -fn drain + Unpin, R, Y>( - gen: &mut G, - inout: Vec<(R, GeneratorState)>, -) where - Y: Debug + PartialEq, - G::Return: Debug + PartialEq, -{ - let mut gen = Pin::new(gen); - - for (input, out) in inout { - assert_eq!(gen.as_mut().resume(input), out); - } -} - -static DROPS: AtomicUsize = AtomicUsize::new(0); - -#[derive(Debug, PartialEq)] -struct DropMe; - -impl Drop for DropMe { - fn drop(&mut self) { - DROPS.fetch_add(1, Ordering::SeqCst); - } -} - -fn expect_drops(expected_drops: usize, f: impl FnOnce() -> T) -> T { - DROPS.store(0, Ordering::SeqCst); - - let res = f(); - - let actual_drops = DROPS.load(Ordering::SeqCst); - assert_eq!(actual_drops, expected_drops); - res -} - -fn main() { - drain( - &mut |mut b| { - while b != 0 { - b = yield (b + 1); - } - -1 - }, - vec![(1, Yielded(2)), (-45, Yielded(-44)), (500, Yielded(501)), (0, Complete(-1))], - ); - - expect_drops(2, || drain(&mut |a| yield a, vec![(DropMe, Yielded(DropMe))])); - - expect_drops(6, || { - drain( - &mut |a| yield yield a, - vec![(DropMe, Yielded(DropMe)), (DropMe, Yielded(DropMe)), (DropMe, Complete(DropMe))], - ) - }); - - #[allow(unreachable_code)] - expect_drops(2, || drain(&mut |a| yield return a, vec![(DropMe, Complete(DropMe))])); - - expect_drops(2, || { - drain( - &mut |a: DropMe| { - if false { yield () } else { a } - }, - vec![(DropMe, Complete(DropMe))], - ) - }); - - expect_drops(4, || { - drain( - #[allow(unused_assignments, unused_variables)] - &mut |mut a: DropMe| { - a = yield; - a = yield; - a = yield; - }, - vec![ - (DropMe, Yielded(())), - (DropMe, Yielded(())), - (DropMe, Yielded(())), - (DropMe, Complete(())), - ], - ) - }); -} diff --git a/src/test/ui/generator/smoke.rs b/src/test/ui/generator/smoke.rs deleted file mode 100644 index 7a917a05d..000000000 --- a/src/test/ui/generator/smoke.rs +++ /dev/null @@ -1,177 +0,0 @@ -// run-pass - -// revisions: default nomiropt -//[nomiropt]compile-flags: -Z mir-opt-level=0 - -// ignore-emscripten no threads support -// compile-flags: --test - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; -use std::thread; - -#[test] -fn simple() { - let mut foo = || { - if false { - yield; - } - }; - - match Pin::new(&mut 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 Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn simple_yield() { - let mut foo = || { - yield; - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn yield_capture() { - let b = String::from("foo"); - let mut foo = || { - yield b; - }; - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut 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 Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "bar" => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut 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 Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut 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 Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut 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 Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(ref s) if *s == "a" => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - }).join().unwrap(); -} diff --git a/src/test/ui/generator/static-generators.rs b/src/test/ui/generator/static-generators.rs deleted file mode 100644 index d098bf1e6..000000000 --- a/src/test/ui/generator/static-generators.rs +++ /dev/null @@ -1,20 +0,0 @@ -// run-pass - -#![feature(generators, generator_trait)] - -use std::pin::Pin; -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 _); - }; - // SAFETY: We shadow the original generator variable so have no safe API to - // move it after this point. - let mut generator = unsafe { Pin::new_unchecked(&mut generator) }; - assert_eq!(generator.as_mut().resume(()), GeneratorState::Yielded(())); - assert_eq!(generator.as_mut().resume(()), GeneratorState::Complete(())); -} diff --git a/src/test/ui/generator/static-mut-reference-across-yield.rs b/src/test/ui/generator/static-mut-reference-across-yield.rs deleted file mode 100644 index 0fa6d9cdc..000000000 --- a/src/test/ui/generator/static-mut-reference-across-yield.rs +++ /dev/null @@ -1,32 +0,0 @@ -// build-pass -// revisions: mir thir -// [thir]compile-flags: -Zthir-unsafeck - -#![feature(generators)] - -static mut A: [i32; 5] = [1, 2, 3, 4, 5]; - -fn is_send_sync(_: T) {} - -fn main() { - unsafe { - let gen_index = static || { - let u = A[{ - yield; - 1 - }]; - }; - let gen_match = static || match A { - i if { - yield; - true - } => - { - () - } - _ => (), - }; - is_send_sync(gen_index); - is_send_sync(gen_match); - } -} diff --git a/src/test/ui/generator/static-not-unpin.rs b/src/test/ui/generator/static-not-unpin.rs deleted file mode 100644 index cfcb94737..000000000 --- a/src/test/ui/generator/static-not-unpin.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(generators)] - -// normalize-stderr-test "std::pin::Unpin" -> "std::marker::Unpin" - -use std::marker::Unpin; - -fn assert_unpin(_: T) { -} - -fn main() { - let mut generator = static || { - yield; - }; - assert_unpin(generator); //~ ERROR E0277 -} diff --git a/src/test/ui/generator/static-not-unpin.stderr b/src/test/ui/generator/static-not-unpin.stderr deleted file mode 100644 index e3859595f..000000000 --- a/src/test/ui/generator/static-not-unpin.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]` cannot be unpinned - --> $DIR/static-not-unpin.rs:14:18 - | -LL | assert_unpin(generator); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]` - | | - | required by a bound introduced by this call - | - = note: consider using `Box::pin` -note: required by a bound in `assert_unpin` - --> $DIR/static-not-unpin.rs:7:20 - | -LL | fn assert_unpin(_: T) { - | ^^^^^ required by this bound in `assert_unpin` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/static-reference-across-yield.rs b/src/test/ui/generator/static-reference-across-yield.rs deleted file mode 100644 index 23b11593b..000000000 --- a/src/test/ui/generator/static-reference-across-yield.rs +++ /dev/null @@ -1,16 +0,0 @@ -// build-pass -#![feature(generators)] - -static A: [i32; 5] = [1, 2, 3, 4, 5]; - -fn main() { - static || { - let u = A[{yield; 1}]; - }; - static || { - match A { - i if { yield; true } => (), - _ => (), - } - }; -} diff --git a/src/test/ui/generator/too-live-local-in-immovable-gen.rs b/src/test/ui/generator/too-live-local-in-immovable-gen.rs deleted file mode 100644 index e0b856db7..000000000 --- a/src/test/ui/generator/too-live-local-in-immovable-gen.rs +++ /dev/null @@ -1,21 +0,0 @@ -// run-pass -#![allow(unused_unsafe)] - -#![feature(generators)] - -fn main() { - unsafe { - static move || { //~ WARN unused generator that must be used - // 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 - }; - let _ = &a; - }; - } -} diff --git a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr b/src/test/ui/generator/too-live-local-in-immovable-gen.stderr deleted file mode 100644 index e262f213f..000000000 --- a/src/test/ui/generator/too-live-local-in-immovable-gen.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/too-live-local-in-immovable-gen.rs:8:9 - | -LL | / static move || { -LL | | // Tests that the generator transformation finds out that `a` is not live -LL | | // during the yield expression. Type checking will also compute liveness -LL | | // and it should also find out that `a` is not live. -... | -LL | | let _ = &a; -LL | | }; - | |_________^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/too-many-parameters.rs b/src/test/ui/generator/too-many-parameters.rs deleted file mode 100644 index 7a353ea29..000000000 --- a/src/test/ui/generator/too-many-parameters.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(generators)] - -fn main() { - |(), ()| { - //~^ error: too many parameters for a generator - yield; - }; -} diff --git a/src/test/ui/generator/too-many-parameters.stderr b/src/test/ui/generator/too-many-parameters.stderr deleted file mode 100644 index 22d40db3f..000000000 --- a/src/test/ui/generator/too-many-parameters.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0628]: too many parameters for a generator (expected 0 or 1 parameters) - --> $DIR/too-many-parameters.rs:4:5 - | -LL | |(), ()| { - | ^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0628`. diff --git a/src/test/ui/generator/type-mismatch-error.rs b/src/test/ui/generator/type-mismatch-error.rs deleted file mode 100644 index d39c788a8..000000000 --- a/src/test/ui/generator/type-mismatch-error.rs +++ /dev/null @@ -1,22 +0,0 @@ -//! Test that we get the expected type mismatch error instead of "closure is expected to take 0 -//! arguments" (which got introduced after implementing resume arguments). - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn f(_: G, _: G::Return) {} - -fn main() { - f( - |a: u8| { - if false { - yield (); - } else { - a - //~^ error: `if` and `else` have incompatible types - } - }, - 0u8, - ); -} diff --git a/src/test/ui/generator/type-mismatch-error.stderr b/src/test/ui/generator/type-mismatch-error.stderr deleted file mode 100644 index 8f5949533..000000000 --- a/src/test/ui/generator/type-mismatch-error.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: `if` and `else` have incompatible types - --> $DIR/type-mismatch-error.rs:16:17 - | -LL | / if false { -LL | | yield (); - | | --------- - | | | | - | | | help: consider removing this semicolon - | | expected because of this -LL | | } else { -LL | | a - | | ^ expected `()`, found `u8` -LL | | -LL | | } - | |_____________- `if` and `else` have incompatible types - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.rs b/src/test/ui/generator/type-mismatch-signature-deduction.rs deleted file mode 100644 index 8d1ce6c7a..000000000 --- a/src/test/ui/generator/type-mismatch-signature-deduction.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn foo() -> impl Generator { - //~^ ERROR type mismatch - || { - if false { - return Ok(6); - } - - yield (); - - 5 //~ ERROR mismatched types [E0308] - } -} - -fn main() {} diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.stderr b/src/test/ui/generator/type-mismatch-signature-deduction.stderr deleted file mode 100644 index b98da1ed8..000000000 --- a/src/test/ui/generator/type-mismatch-signature-deduction.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/type-mismatch-signature-deduction.rs:14:9 - | -LL | 5 - | ^ expected enum `Result`, found integer - | - = note: expected enum `Result<{integer}, _>` - found type `{integer}` -note: return type inferred to be `Result<{integer}, _>` here - --> $DIR/type-mismatch-signature-deduction.rs:9:20 - | -LL | return Ok(6); - | ^^^^^ -help: try wrapping the expression in a variant of `Result` - | -LL | Ok(5) - | +++ + -LL | Err(5) - | ++++ + - -error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:7:5: 7:7] as Generator>::Return == i32` - --> $DIR/type-mismatch-signature-deduction.rs:5:13 - | -LL | fn foo() -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `i32` - | - = note: expected enum `Result<{integer}, _>` - found type `i32` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0271, E0308. -For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/generator/unresolved-ct-var.rs b/src/test/ui/generator/unresolved-ct-var.rs deleted file mode 100644 index 0a1570fc2..000000000 --- a/src/test/ui/generator/unresolved-ct-var.rs +++ /dev/null @@ -1,14 +0,0 @@ -// incremental -// edition:2021 - -fn main() { - let _ = async { - let s = std::array::from_fn(|_| ()).await; - //~^ ERROR `[(); _]` is not a future - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - //~| ERROR type inside `async` block must be known in this context - }; -} diff --git a/src/test/ui/generator/unresolved-ct-var.stderr b/src/test/ui/generator/unresolved-ct-var.stderr deleted file mode 100644 index fdf00dfad..000000000 --- a/src/test/ui/generator/unresolved-ct-var.stderr +++ /dev/null @@ -1,78 +0,0 @@ -error[E0277]: `[(); _]` is not a future - --> $DIR/unresolved-ct-var.rs:6:44 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ---------------------------^^^^^^ - | | | - | | `[(); _]` is not a future - | | help: remove the `.await` - | this call returns `[(); _]` - | - = help: the trait `Future` is not implemented for `[(); _]` - = note: [(); _] must be a future or must implement `IntoFuture` to be awaited - = note: required for `[(); _]` to implement `IntoFuture` - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/unresolved-ct-var.rs:6:17 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `from_fn` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/unresolved-ct-var.rs:6:44 - | -LL | let s = std::array::from_fn(|_| ()).await; - | ^^^^^^ - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0277, E0698. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/xcrate-reachable.rs b/src/test/ui/generator/xcrate-reachable.rs deleted file mode 100644 index 1b1cff338..000000000 --- a/src/test/ui/generator/xcrate-reachable.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass - -// aux-build:xcrate-reachable.rs - -#![feature(generator_trait)] - -extern crate xcrate_reachable as foo; - -use std::ops::Generator; -use std::pin::Pin; - -fn main() { - Pin::new(&mut foo::foo()).resume(()); -} diff --git a/src/test/ui/generator/xcrate.rs b/src/test/ui/generator/xcrate.rs deleted file mode 100644 index 40986bbeb..000000000 --- a/src/test/ui/generator/xcrate.rs +++ /dev/null @@ -1,30 +0,0 @@ -// run-pass - -// aux-build:xcrate.rs - -#![feature(generators, generator_trait)] - -extern crate xcrate; - -use std::ops::{GeneratorState, Generator}; -use std::pin::Pin; - -fn main() { - let mut foo = xcrate::foo(); - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - let mut foo = xcrate::bar(3); - - match Pin::new(&mut foo).resume(()) { - GeneratorState::Yielded(3) => {} - s => panic!("bad state: {:?}", s), - } - match Pin::new(&mut foo).resume(()) { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} diff --git a/src/test/ui/generator/yield-in-args-rev.rs b/src/test/ui/generator/yield-in-args-rev.rs deleted file mode 100644 index 4c99bb3ef..000000000 --- a/src/test/ui/generator/yield-in-args-rev.rs +++ /dev/null @@ -1,19 +0,0 @@ -// run-pass -#![allow(dead_code)] - -// 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() { - || { //~ WARN unused generator that must be used - let b = true; - foo(yield, &b); - }; -} - -fn main() { } 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 a87248f66..000000000 --- a/src/test/ui/generator/yield-in-args-rev.stderr +++ /dev/null @@ -1,14 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-in-args-rev.rs:13:5 - | -LL | / || { -LL | | let b = true; -LL | | foo(yield, &b); -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/yield-in-args.rs b/src/test/ui/generator/yield-in-args.rs deleted file mode 100644 index 80110af55..000000000 --- a/src/test/ui/generator/yield-in-args.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(generators)] - -fn foo(_b: &bool, _a: ()) {} - -fn main() { - || { - let b = true; - foo(&b, yield); //~ ERROR - }; -} diff --git a/src/test/ui/generator/yield-in-args.stderr b/src/test/ui/generator/yield-in-args.stderr deleted file mode 100644 index ee6d22c27..000000000 --- a/src/test/ui/generator/yield-in-args.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-in-args.rs:8:13 - | -LL | foo(&b, yield); - | ^^ ----- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/generator/yield-in-box.rs b/src/test/ui/generator/yield-in-box.rs deleted file mode 100644 index dd6fa7c15..000000000 --- a/src/test/ui/generator/yield-in-box.rs +++ /dev/null @@ -1,24 +0,0 @@ -// run-pass -// Test that box-statements with yields in them work. - -#![feature(generators, box_syntax, generator_trait)] -use std::pin::Pin; -use std::ops::Generator; -use std::ops::GeneratorState; - -fn main() { - let x = 0i32; - || { //~ WARN unused generator that must be used - let y = 2u32; - { - let _t = box (&x, yield 0, &y); - } - match box (&x, yield 0, &y) { - _t => {} - } - }; - - let mut g = |_| box yield; - assert_eq!(Pin::new(&mut g).resume(1), GeneratorState::Yielded(())); - assert_eq!(Pin::new(&mut g).resume(2), GeneratorState::Complete(box 2)); -} diff --git a/src/test/ui/generator/yield-in-box.stderr b/src/test/ui/generator/yield-in-box.stderr deleted file mode 100644 index 9d03ee008..000000000 --- a/src/test/ui/generator/yield-in-box.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-in-box.rs:11:5 - | -LL | / || { -LL | | let y = 2u32; -LL | | { -LL | | let _t = box (&x, yield 0, &y); -... | -LL | | } -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/yield-in-const.rs b/src/test/ui/generator/yield-in-const.rs deleted file mode 100644 index fe5ca822c..000000000 --- a/src/test/ui/generator/yield-in-const.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(generators)] - -const A: u8 = { yield 3u8; 3u8}; -//~^ ERROR yield expression outside - -fn main() {} diff --git a/src/test/ui/generator/yield-in-const.stderr b/src/test/ui/generator/yield-in-const.stderr deleted file mode 100644 index dcf4fe63e..000000000 --- a/src/test/ui/generator/yield-in-const.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-in-const.rs:3:17 - | -LL | const A: u8 = { yield 3u8; 3u8}; - | ^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/src/test/ui/generator/yield-in-function.rs b/src/test/ui/generator/yield-in-function.rs deleted file mode 100644 index 29b811621..000000000 --- a/src/test/ui/generator/yield-in-function.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(generators)] - -fn main() { yield; } -//~^ ERROR yield expression outside diff --git a/src/test/ui/generator/yield-in-function.stderr b/src/test/ui/generator/yield-in-function.stderr deleted file mode 100644 index 51cce198c..000000000 --- a/src/test/ui/generator/yield-in-function.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-in-function.rs:3:13 - | -LL | fn main() { yield; } - | ^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/src/test/ui/generator/yield-in-initializer.rs b/src/test/ui/generator/yield-in-initializer.rs deleted file mode 100644 index 0cab36e5f..000000000 --- a/src/test/ui/generator/yield-in-initializer.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass - -#![feature(generators)] - -fn main() { - static || { //~ WARN unused generator that must be used - 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 - }; - let _ = &opt; - } - }; -} diff --git a/src/test/ui/generator/yield-in-initializer.stderr b/src/test/ui/generator/yield-in-initializer.stderr deleted file mode 100644 index ed14a2e32..000000000 --- a/src/test/ui/generator/yield-in-initializer.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-in-initializer.rs:6:5 - | -LL | / static || { -LL | | loop { -LL | | // Test that `opt` is not live across the yield, even when borrowed in a loop -LL | | // See https://github.com/rust-lang/rust/issues/52792 -... | -LL | | } -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/yield-in-static.rs b/src/test/ui/generator/yield-in-static.rs deleted file mode 100644 index d27fbb33b..000000000 --- a/src/test/ui/generator/yield-in-static.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(generators)] - -static B: u8 = { yield 3u8; 3u8}; -//~^ ERROR yield expression outside - -fn main() {} diff --git a/src/test/ui/generator/yield-in-static.stderr b/src/test/ui/generator/yield-in-static.stderr deleted file mode 100644 index d867f3ad3..000000000 --- a/src/test/ui/generator/yield-in-static.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-in-static.rs:3:18 - | -LL | static B: u8 = { yield 3u8; 3u8}; - | ^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0627`. diff --git a/src/test/ui/generator/yield-outside-generator-issue-78653.rs b/src/test/ui/generator/yield-outside-generator-issue-78653.rs deleted file mode 100644 index 4e8050c81..000000000 --- a/src/test/ui/generator/yield-outside-generator-issue-78653.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(generators)] - -fn main() { - yield || for i in 0 { } - //~^ ERROR yield expression outside of generator literal - //~| ERROR `{integer}` is not an iterator -} diff --git a/src/test/ui/generator/yield-outside-generator-issue-78653.stderr b/src/test/ui/generator/yield-outside-generator-issue-78653.stderr deleted file mode 100644 index dcfb21174..000000000 --- a/src/test/ui/generator/yield-outside-generator-issue-78653.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0627]: yield expression outside of generator literal - --> $DIR/yield-outside-generator-issue-78653.rs:4:5 - | -LL | yield || for i in 0 { } - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: `{integer}` is not an iterator - --> $DIR/yield-outside-generator-issue-78653.rs:4:23 - | -LL | yield || for i in 0 { } - | ^ `{integer}` is not an iterator - | - = help: the trait `Iterator` is not implemented for `{integer}` - = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` - = note: required for `{integer}` to implement `IntoIterator` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0627. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/generator/yield-subtype.rs b/src/test/ui/generator/yield-subtype.rs deleted file mode 100644 index cb3fc9091..000000000 --- a/src/test/ui/generator/yield-subtype.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(dead_code)] - -#![feature(generators)] - -fn bar<'a>() { - let a: &'static str = "hi"; - let b: &'a str = a; - - || { //~ WARN unused generator that must be used - yield a; - yield b; - }; -} - -fn main() {} diff --git a/src/test/ui/generator/yield-subtype.stderr b/src/test/ui/generator/yield-subtype.stderr deleted file mode 100644 index 97862e91c..000000000 --- a/src/test/ui/generator/yield-subtype.stderr +++ /dev/null @@ -1,14 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-subtype.rs:11:5 - | -LL | / || { -LL | | yield a; -LL | | yield b; -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/ui/generator/yield-while-iterating.rs b/src/test/ui/generator/yield-while-iterating.rs deleted file mode 100644 index 985e5d8bd..000000000 --- a/src/test/ui/generator/yield-while-iterating.rs +++ /dev/null @@ -1,75 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::cell::Cell; -use std::pin::Pin; - -fn yield_during_iter_owned_data(x: Vec) { - // The generator owns `x`, so we error out when yielding with a - // reference to it. This winds up becoming a rather confusing - // regionck error -- in particular, we would freeze with the - // reference in scope, and it doesn't live long enough. - let _b = move || { - for p in &x { //~ ERROR - yield(); - } - }; -} - -fn yield_during_iter_borrowed_slice(x: &[i32]) { - let _b = move || { - for p in x { - yield(); - } - }; -} - -fn yield_during_iter_borrowed_slice_2() { - let mut x = vec![22_i32]; - let _b = || { - for p in &x { - yield(); - } - }; - println!("{:?}", x); -} - -fn yield_during_iter_borrowed_slice_3() { - // OK to take a mutable ref to `x` and yield - // up pointers from it: - let mut x = vec![22_i32]; - let mut b = || { - for p in &mut x { - yield p; - } - }; - Pin::new(&mut b).resume(()); -} - -fn yield_during_iter_borrowed_slice_4() { - // ...but not OK to do that while reading - // from `x` too - let mut x = vec![22_i32]; - let mut b = || { - for p in &mut x { - yield p; - } - }; - println!("{}", x[0]); //~ ERROR - Pin::new(&mut b).resume(()); -} - -fn yield_during_range_iter() { - // Should be OK. - let mut b = || { - let v = vec![1,2,3]; - let len = v.len(); - for i in 0..len { - let x = v[i]; - yield x; - } - }; - Pin::new(&mut b).resume(()); -} - -fn main() { } diff --git a/src/test/ui/generator/yield-while-iterating.stderr b/src/test/ui/generator/yield-while-iterating.stderr deleted file mode 100644 index b65634752..000000000 --- a/src/test/ui/generator/yield-while-iterating.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-iterating.rs:13:18 - | -LL | for p in &x { - | ^^ -LL | yield(); - | ------- possible yield occurs here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/yield-while-iterating.rs:58:20 - | -LL | let mut b = || { - | -- mutable borrow occurs here -LL | for p in &mut x { - | - first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x[0]); - | ^ immutable borrow occurs here -LL | Pin::new(&mut b).resume(()); - | ------ mutable borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0502, E0626. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/generator/yield-while-local-borrowed.rs b/src/test/ui/generator/yield-while-local-borrowed.rs deleted file mode 100644 index 061a64dbc..000000000 --- a/src/test/ui/generator/yield-while-local-borrowed.rs +++ /dev/null @@ -1,49 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::cell::Cell; -use std::pin::Pin; - -fn borrow_local_inline() { - // Not OK to yield with a borrow of a temporary. - // - // (This error occurs because the region shows up in the type of - // `b` and gets extended by region inference.) - let mut b = move || { - let a = &mut 3; - //~^ ERROR borrow may still be in use when generator yields - yield(); - println!("{}", a); - }; - Pin::new(&mut b).resume(()); -} - -fn borrow_local_inline_done() { - // No error here -- `a` is not in scope at the point of `yield`. - let mut b = move || { - { - let a = &mut 3; - } - yield(); - }; - Pin::new(&mut b).resume(()); -} - -fn borrow_local() { - // Not OK to yield with a borrow of a temporary. - // - // (This error occurs because the region shows up in the type of - // `b` and gets extended by region inference.) - let mut b = move || { - let a = 3; - { - let b = &a; - //~^ ERROR borrow may still be in use when generator yields - yield(); - println!("{}", b); - } - }; - Pin::new(&mut b).resume(()); -} - -fn main() { } diff --git a/src/test/ui/generator/yield-while-local-borrowed.stderr b/src/test/ui/generator/yield-while-local-borrowed.stderr deleted file mode 100644 index c1513ef9b..000000000 --- a/src/test/ui/generator/yield-while-local-borrowed.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-local-borrowed.rs:13:17 - | -LL | let a = &mut 3; - | ^^^^^^ -LL | -LL | yield(); - | ------- possible yield occurs here - -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-local-borrowed.rs:40:21 - | -LL | let b = &a; - | ^^ -LL | -LL | yield(); - | ------- possible yield occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.rs b/src/test/ui/generator/yield-while-ref-reborrowed.rs deleted file mode 100644 index a03ef945d..000000000 --- a/src/test/ui/generator/yield-while-ref-reborrowed.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::cell::Cell; -use std::pin::Pin; - -fn reborrow_shared_ref(x: &i32) { - // This is OK -- we have a borrow live over the yield, but it's of - // data that outlives the generator. - let mut b = move || { - let a = &*x; - yield(); - println!("{}", a); - }; - Pin::new(&mut b).resume(()); -} - -fn reborrow_mutable_ref(x: &mut i32) { - // This is OK -- we have a borrow live over the yield, but it's of - // data that outlives the generator. - let mut b = move || { - let a = &mut *x; - yield(); - println!("{}", a); - }; - Pin::new(&mut b).resume(()); -} - -fn reborrow_mutable_ref_2(x: &mut i32) { - // ...but not OK to go on using `x`. - let mut b = || { - let a = &mut *x; - yield(); - println!("{}", a); - }; - println!("{}", x); //~ ERROR - Pin::new(&mut b).resume(()); -} - -fn main() { } diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.stderr b/src/test/ui/generator/yield-while-ref-reborrowed.stderr deleted file mode 100644 index 47147f9c0..000000000 --- a/src/test/ui/generator/yield-while-ref-reborrowed.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access - --> $DIR/yield-while-ref-reborrowed.rs:36:20 - | -LL | let mut b = || { - | -- generator construction occurs here -LL | let a = &mut *x; - | -- first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x); - | ^ second borrow occurs here -LL | Pin::new(&mut b).resume(()); - | ------ first borrow later used here - | - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/generator/yielding-in-match-guards.rs b/src/test/ui/generator/yielding-in-match-guards.rs deleted file mode 100644 index 4e89fc975..000000000 --- a/src/test/ui/generator/yielding-in-match-guards.rs +++ /dev/null @@ -1,53 +0,0 @@ -// build-pass -// edition:2018 - -// This test is derived from -// https://github.com/rust-lang/rust/issues/72651#issuecomment-668720468 - -// This test demonstrates that, in `async fn g()`, -// indeed a temporary borrow `y` from `x` is live -// while `f().await` is being evaluated. -// Thus, `&'_ u8` should be included in type signature -// of the underlying generator. - -#![feature(if_let_guard)] - -async fn f() -> u8 { 1 } -async fn foo() -> [bool; 10] { [false; 10] } - -pub async fn g(x: u8) { - match x { - y if f().await == y => (), - _ => (), - } -} - -// #78366: check the reference to the binding is recorded even if the binding is not autorefed - -async fn h(x: usize) { - match x { - y if foo().await[y] => (), - _ => (), - } -} - -async fn i(x: u8) { - match x { - y if f().await == y + 1 => (), - _ => (), - } -} - -async fn j(x: u8) { - match x { - y if let (1, 42) = (f().await, y) => (), - _ => (), - } -} - -fn main() { - let _ = g(10); - let _ = h(9); - let _ = i(8); - let _ = j(7); -} -- cgit v1.2.3