-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace usage of ResumeTy
in async lowering with Context
#105250
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
// Resume argument type, which should be `&mut Context<'_>`. | ||
// NOTE: Using the `'static` lifetime here is technically cheating. | ||
// The `Future::poll` argument really is `&'a mut Context<'b>`, but inferring that | ||
// lifetime would lead to lifetime errors, as those lifetimes are considered captured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since they are on the generator argument, why would they get captured?
ah this is #68923
Please reference that issue here, as we'll lose the connection now that ResumeTy
is dead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 I slightly reworded that comment, referencing the given issue, and have also rebased the PR.
14c48d4
to
9dbb189
Compare
@bors r+ |
Replace usage of `ResumeTy` in async lowering with `Context` Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air. fixes rust-lang#104828 and rust-lang#104321 (comment) r? `@oli-obk`
Replace usage of `ResumeTy` in async lowering with `Context` Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air. fixes rust-lang#104828 and rust-lang#104321 (comment) r? ``@oli-obk``
Replace usage of `ResumeTy` in async lowering with `Context` Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air. fixes rust-lang#104828 and rust-lang#104321 (comment) r? ```@oli-obk```
Failed in rollup: #105335 (comment) |
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air.
9dbb189
to
cf031a3
Compare
Looks like this was conflicting with #105180. I rebased, but I seem to have two
|
@bors r+ |
Heads up that this probably broke #105501. @khuey is checking if reverting this PR makes the code compile again (that they can't share) -- This probably has to do with the same old generator-interior lifetime erasure issue, since now we have a type that has two lifetimes in the generator interior 😅. Unclear which lifetime in Anyways, at this rate, this will unfortunately probably make its way to beta, but we'll probably see regressions in the crater run after beta is cut. |
Reverting this does indeed fix my problem. |
@khuey can you do me a favor and try it with this snippet here: That turns the |
Using that hunk doesn't change anything. |
Oh well :-( I think reverting back to I hope adding a In the meantime, it would be nice to have a minimal repro and maybe a regression test for #105501 so that does not regress again. Either way, I should be able to open a revert PR tomorrow evening or monday. |
Please do a similar fix to #105082 instead and make sure that the generated MIR matches the function signature. Mismatches between the function signature and the MIR are bound to give issues apart from this type compatibility. For example without #105082 a projection on the return place went completely haywire causing an assignment of an i32 value to a () place which was correctly rejected with a crash. |
this also causes a regression for the following (reduced from actual production code ;)) code that works fine on stable and beta:
broken on current nightly as well as on a default build of 71ec145 thanks @Blub for reporting and reducing the reproducer! |
Further reduced: fn is_unwindsafe(_: impl std::panic::UnwindSafe) {}
fn main() {
is_unwindsafe(async {
// this needs an inner await point
async {}.await;
});
} Thanks for the repro. I will work on a fix later today. |
…rm-resumety, r=tmandry Revert "Replace usage of `ResumeTy` in async lowering with `Context`" Reverts rust-lang#105250 Fixes: rust-lang#105501 Following instructions from [forge](https://forge.rust-lang.org/compiler/reviews.html#reverts). This change introduced a breaking change that is not actionable nor relevant, and is blocking updates to our toolchain. Along with other comments on the CL marking issues that are fixed by reverts, reverting is best until these issues can be resolved cc. `@Swatinem`
This was a regression from the reverted rust-lang#105250 which is now covered by a test.
…trochenkov Test that async blocks are `UnwindSafe` This was a regression from the reverted rust-lang#105250 which is now covered by a test.
This was a regression from the reverted rust-lang#105250 which is now covered by a test.
This changes from the stdlib supported `ResumeTy`, and converting that to a `&mut Context<'_>` to directly use `&mut Context<'_>` in lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. The PR is currently failing as it depends on `-Zdrop-tracking-mir` becoming the default, so that the compiler does not falsly believe the context is being held across await points,which would make async blocks `!Send` and `!UnwindSafe`. However it also still fails the testcase added in rust-lang#106264 for reasons I don’t understand.
…ty, r=tmandry Revert "Replace usage of `ResumeTy` in async lowering with `Context`" Reverts rust-lang/rust#105250 Fixes: #105501 Following instructions from [forge](https://forge.rust-lang.org/compiler/reviews.html#reverts). This change introduced a breaking change that is not actionable nor relevant, and is blocking updates to our toolchain. Along with other comments on the CL marking issues that are fixed by reverts, reverting is best until these issues can be resolved cc. `@Swatinem`
Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass, this will use `&mut Context<'_>` directly in HIR lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass, this will use `&mut Context<'_>` directly in HIR lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass, this will use `&mut Context<'_>` directly in HIR lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass, this will use `&mut Context<'_>` directly in HIR lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass, this will use `&mut Context<'_>` directly in HIR lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass, this will use `&mut Context<'_>` directly in HIR lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
Instead of using the stdlib supported `ResumeTy`, which is being converting to a `&mut Context<'_>` during the Generator MIR pass, this will use `&mut Context<'_>` directly in HIR lowering. It pretty much reverts rust-lang#105977 and re-applies an updated version of rust-lang#105250. This still fails the testcase added in rust-lang#106264 however, for reasons I don’t understand.
Replaces using
ResumeTy
/get_context
in favor of using&'static mut Context<'_>
.Usage of the
'static
lifetime here is technically "cheating", and replaces the raw pointer inResumeTy
and theget_context
fn that pulls the correct lifetimes out of thin air.fixes #104828 and #104321 (comment)
r? @oli-obk