Rust Async Working Group
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Open discussion: May 2023 This is the doc for open discussion within wg-async about various design questions and other topics. Please feel free to propose a topic below. On the day of the meeting, we'll do a quick poll to sort the topics by interest and then go through them one by one. If you have a brief (under 5 min) introduction prepared for the group, we'll take that into account as we prioritize the topics. ###### tags: `open-discussion` Leave discussion topics below. --- ## AFIT blog post feedback tmandry: Placeholder for discussing any interesting feedback we got. Discussion threads: - https://old.reddit.com/r/rust/comments/136o73k/stabilizing_async_fn_in_traits_in_2023_inside/ - https://news.ycombinator.com/item?id=35811578 Summary: * Generally positive * Some people didn't like all the times you have to write `+ Send`, `+ 'static` etc. * Nothing revelatory --- ## Lang team discussion updates tmandry: Summary of lang team discussion yesterday and the upcoming one for next week. Yesterday: [Return Position Impl Trait in Trait Stabilization](https://hackmd.io/ZEnb67s3RkysfNK2-tBMIw?view) * Lang team seems on board with stabilizing RPITIT. * At a high level, most disagreement (from outside the lang team) comes from a belief that this complicates the language rather than simplifies it. * Question about whether `#[refine]` is worth it ([RFC 3245](https://rust-lang.github.io/rfcs/3245-refined-impls.html)). MVP will not allow you to write impls that require `#[refine]`, i.e., you cannot add extra information like a concrete type or additional bounds to your impl. * We will allow auto traits to leak without `#[refine]`, so you can write ```rust trait Foo { fn foo(&self) -> impl Future<Output = ()> + Send + '_; // ^^^^^^ } ``` and it will be compatible with using `async fn` in an impl, once that's stable. Next week: Associated return types / Return type notation * RFC draft is still being worked on: [Minimal associated return type notation](/KJaC_dhZTmyR_Ja9ghdZvg) eholk: Don't love the idea of using an attribute for semantically meaningful things (`#[refine]`) tmandry: I conceptualize it more as a lint. Semantics are the thing you put in the signature. eholk: That makes sense tmandry: Kind of like a shorter `#[allow(...)]`. Maybe we'd stabilize as `#[allow(refine)]`? eholk: That also looks weird, maybe an argument for just `#[refine]`. Code smell when you `#[allow(..)]` a lot tmandry: Mod-level `#![allow(..)]` can work --- ## Difference between `async fn` desugaring and RPITIT tmandry: Let's say you have ```rust trait Foo { async fn foo(&self, x: &i32); } ``` What does this desugar to? You might think it's something like ```rust trait Foo { fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = ()> + 'a + 'b; } ``` but this promises that the return type outlives `'a` and `'b`, but in reality async fn doesn't promise that. It allows the return type to *name* both `'a` and `'b`, and therefore the return type must be valid while *both* `'a` and `'b` are valid, but that's not the same as saying it outlives both `'a` and `'b`. it's really more like ```rust trait Captures<T> {} impl<T, U> Captures<T> for U {} trait Foo { fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl Future<Output = ()> + Captures<(&'a (), &'b ())>; } ``` The only function of the `Captures` trait is to let you *mention* `'a` and `'b` in the RPITIT, which by the RPITIT rules then allows you to capture those lifetimes in the actual return type. We can imagine new syntax for this: ```rust trait Foo { fn foo<'a, 'b>(&'a self, x: &'b i32) -> impl<'a, 'b> Future<Output = ()>; } ``` So, what are we doing in the RFC? 1. For stabilizing RPITIT, we only need to consider the case where you use RPITIT in the trait and want to write async fn in the impl later. * If you have one lifetime, this will "just work" due to existing rules about projections and outlives. * If you have multiple lifetimes, you can use the `Captures` trick with `async fn`, but it's ugly. * If you have multiple lifetimes and write `+ 'a + 'b`, I'm not sure with `async fn` in the future. We might find a way to make it work, but you might just need to wait for AFIT to stabilize. eholk: Can I migrate a trait from `-> impl Future + '_` to `async fn` in the future? In other words, are `-> impl Future + '_` and `async fn` exactly sugar for each other? tmandry: Yes, when there's one lifetime, but not for multiple lifetimes. eholk: What does `fn foo(&self, _: &i32) -> impl Future<Output = ()> + '_` correspond to then? eholk: The capture rules are starting to make me a little concerned. Because AFIT is really desirable, I expect we'll start seeing a lot of `-> impl Future` traits show up in the ecosystem once RPITIT is stabilized. Once AFIT becomes available, crates may want to rewrite their `-> impl Future` traits as `async fn`, but to do that we need to make sure they can write `-> impl Future` in a forward-compatible way. It sounds like that's going to be possible but easy to get wrong with the current plan. eholk: To be clear though, I don't want to block RPITIT, I think it's a good feature that we should add. I want to make sure we can avoid future footguns though. --- ## Topic name: prompt --- ## Topic name: prompt ---

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully