[WIP] Check coroutine upvars and resume ty in dtorck constraint, this time based off of TypingMode by compiler-errors · Pull Request #144158 · rust-lang/rust (original) (raw)
1 error[E0597]: `a` does not live long enough
2 --> $DIR/borrowing.rs:9:46
3 |
- LL | let _b = {
- | -- borrow later stored here
6 LL | let a = 3;
7 | - binding `a` declared here
8 LL | Pin::new(&mut #[coroutine] || yield &a).resume(())
- | -- ^ borrowed value does not live long enough
- | |
+ | ----------^
+ | | |
---
+ | |
+ | `a` dropped here while still borrowed
+ |
+ = note: the temporary is part of an expression at the end of a block;
+ consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
+ help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
+ |
+ LL | let x = Pin::new(&mut #[coroutine] || yield &a).resume(()); x
+ | +++++++ +++
15
16 error[E0597]: `a` does not live long enough
17 --> $DIR/borrowing.rs:16:20
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args coroutine/borrowing.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/coroutine/borrowing.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/coroutine/borrowing" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0597]: `a` does not live long enough
##[error] --> /checkout/tests/ui/coroutine/borrowing.rs:9:46
|
LL | let a = 3;
| - binding `a` declared here
LL | Pin::new(&mut #[coroutine] || yield &a).resume(())
| ----------^
| | |
| | borrowed value does not live long enough
| value captured here by coroutine
| a temporary with access to the borrow is created here ...
LL | //~^ ERROR: `a` does not live long enough
LL | };
| -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for coroutine
| |
| `a` dropped here while still borrowed
|
= note: the temporary is part of an expression at the end of a block;
consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
|
LL | let x = Pin::new(&mut #[coroutine] || yield &a).resume(()); x
| +++++++ +++
error[E0597]: `a` does not live long enough
##[error] --> /checkout/tests/ui/coroutine/borrowing.rs:16:20
|
LL | let _b = {
| -- borrow later stored here
LL | let a = 3;
| - binding `a` declared here
LL | #[coroutine] || {
| -- value captured here by coroutine
LL | yield &a
| ^ borrowed value does not live long enough
...
LL | };
| - `a` dropped here while still borrowed
error: aborting due to 2 previous errors
---
---- [ui] tests/ui/coroutine/check-resume-ty-lifetimes.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/coroutine/check-resume-ty-lifetimes/check-resume-ty-lifetimes.stderr`
diff of stderr:
7 LL | let x: &'static str = yield ();
8 | ^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
9
- error: aborting due to 1 previous error
+ error[E0503]: cannot use `storage` because it was mutably borrowed
+ --> $DIR/check-resume-ty-lifetimes.rs:24:5
+ |
+ LL | |_: &str| {
+ | --------- `storage` is borrowed here
+ ...
+ LL | storage = Some(x);
+ | ------- borrow occurs due to use of `storage` in coroutine
+ ...
+ LL | storage.unwrap()
---
- --> /checkout/tests/ui/coroutine/check-resume-ty-lifetimes.rs:24:5
+ error[E0503]: cannot use `storage` because it was mutably borrowed
+ --> $DIR/check-resume-ty-lifetimes.rs:24:5
+ |
+ LL | |_: &str| {
+ | --------- `storage` is borrowed here
+ ...
+ LL | storage = Some(x);
+ | ------- borrow occurs due to use of `storage` in coroutine
+ ...
+ LL | storage.unwrap()
---
To only update this specific test, also pass `--test-args coroutine/check-resume-ty-lifetimes.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/coroutine/check-resume-ty-lifetimes.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/coroutine/check-resume-ty-lifetimes" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error: lifetime may not live long enough
##[error] --> /checkout/tests/ui/coroutine/check-resume-ty-lifetimes.rs:15:20
|
LL | fn mk_static(s: &str) -> &'static str {
| - let's call the lifetime of this reference `'1`
...
LL | let x: &'static str = yield ();
| ^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
error[E0503]: cannot use `storage` because it was mutably borrowed
##[error] --> /checkout/tests/ui/coroutine/check-resume-ty-lifetimes.rs:24:5
|
LL | |_: &str| {
| --------- `storage` is borrowed here
...
LL | storage = Some(x);
| ------- borrow occurs due to use of `storage` in coroutine
...
LL | storage.unwrap()
---
---- [ui] tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs stdout ----
error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/coroutine/issue-110929-coroutine-conflict-error-ice" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error[E0499]: cannot borrow `*x` as mutable more than once at a time
##[error] --> /checkout/tests/ui/coroutine/issue-110929-coroutine-conflict-error-ice.rs:10:9
|
LL | || yield *&mut *x;
| -- -- first borrow occurs due to use of `*x` in coroutine
| |
| first mutable borrow occurs here
LL | || _ = &mut *x;
| ^^ -- second borrow occurs due to use of `*x` in closure
| |
| second mutable borrow occurs here
LL | };
| - first borrow might be used here, when `_c` is dropped and runs the destructor for coroutine
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0499`.
------------------------------------------
---
11 error: aborting due to 1 previous error
12
Note: some mismatched output was normalized before being compared
- LL | //~^ ERROR cannot borrow `thing` as mutable more than once at a time
+ | ^^^^^^^^^^ second mutable borrow occurs here
+ LL |
+ LL | }
+ | - first borrow might be used here, when `gen` is dropped and runs the destructor for coroutine
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args coroutine/retain-resume-ref.rs`
error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/coroutine/retain-resume-ref.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/coroutine/retain-resume-ref" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0499]: cannot borrow `thing` as mutable more than once at a time
##[error] --> /checkout/tests/ui/coroutine/retain-resume-ref.rs:24: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
LL | //~^ ERROR cannot borrow `thing` as mutable more than once at a time
LL | }
| - first borrow might be used here, when `gen` is dropped and runs the destructor for coroutine
error: aborting due to 1 previous error
---
---- [ui] tests/ui/dropck/coroutine-liveness-1.rs stdout ----
error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/dropck/coroutine-liveness-1.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/dropck/coroutine-liveness-1" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error[E0505]: cannot move out of `recv` because it is borrowed
##[error] --> /checkout/tests/ui/dropck/coroutine-liveness-1.rs:13:10
|
---
...
LL | drop(recv);
| ^^^^ move out of `recv` occurs here
LL | }
| - borrow might be used here, when `_combined_fut` is dropped and runs the destructor for coroutine
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0505`.
------------------------------------------
---- [ui] tests/ui/dropck/coroutine-liveness-2.rs stdout ----
error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/dropck/coroutine-liveness-2.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/dropck/coroutine-liveness-2" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error[E0505]: cannot move out of `recv` because it is borrowed
##[error] --> /checkout/tests/ui/dropck/coroutine-liveness-2.rs🔞10
|
---
...
LL | drop(recv);
| ^^^^ move out of `recv` occurs here
LL | }
| - borrow might be used here, when `_uwu` is dropped and runs the destructor for type `(String, {async block@/checkout/tests/ui/dropck/coroutine-liveness-2.rs:9:25: 9:30})`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0505`.
------------------------------------------