Skip to content

Drop order of async fn arguments doesn't exactly match the equivalent regular fn. #60236

Closed

Description

@davidtwco

While #59823 resolved async fn arguments being dropped before the function was polled, the resulting drop order still does not exactly match the equivalent fn.

This is visible in this playground example which compares the drop order of four functions with and without fn and async fn. This is a behavior of closures which can be seen in this playground example which approximates the desugaring of async fns.

Activity

  1. Centril commented on Apr 30, 2019

    @Centril
    Contributor

    So in my view, this should be considered blocking for the same reason as the other drop issue. However, if it comes to it and we cannot fix it in time for stabilizing, we can feature gate this part and move on.

  2. nikomatsakis commented on Apr 30, 2019

    @nikomatsakis
    Contributor

    The only argument I can come up with in favor of this drop order is basically:

    • the existing drop order of fn is not what we would have wanted (I believe this, but I also doubt its worth trying to change it)
    • having a simple desugaring for async fn is important

    You might make a case that, because people sometimes have to manually desugar into a fn that returns an async block for various reasons, having a simple transformation is important.

    But I think this whole case sounds a bit weak to me -- in contrast, matching fn and async fn as closely as possible feels like what would people would expect

    Of course I also think that the drop order between fn parameters, particularly when intermingled with complex patterns, is highly unlikely to matter, but who's to say what people ultimately rely on.

    Still, this implies that most of the time, people can desugar any which way to use an async move block and it will be fine.

  3. nikomatsakis commented on Apr 30, 2019

    @nikomatsakis
    Contributor

    I'm going to mark this as blocking for now.

  4. self-assigned this
    on Apr 30, 2019
  5. added a commit that references this issue on May 1, 2019
    16939a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaT-langRelevant to the language team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions