Skip to content

Tracking Issue for try_trait_v2, A new design for the ? desugaring (RFC#3058) #84277

Open

Description

@scottmcm

View all comments

This is a tracking issue for the RFC "try_trait_v2: A new design for the ? desugaring" (rust-lang/rfcs#3058).
The feature gate for the issue is #![feature(try_trait_v2)].

This obviates rust-lang/rfcs#1859, tracked in #42327.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

From RFC:

  • What vocabulary should Try use in the associated types/traits? Output+residual, continue+break, or something else entirely?
  • Is it ok for the two traits to be tied together closely, as outlined here, or should they be split up further to allow types that can be only-created or only-destructured?

From experience in nightly:

Implementation history

Activity

  1. added
    T-langRelevant to the language team
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.
    T-libs-api[DEPRECATED; DO NOT USE]
    on Apr 17, 2021
  2. added a commit that references this issue on May 18, 2021
  3. artemii235 commented on Jul 22, 2021

    @artemii235

    We have a problem in our project related to the new question mark desugaring. We use the track_caller feature in From::from implementation of the error types to collect stack traces with generics and auto and negative impl traits magic implemented by @sergeyboyko0791 (https://github.com/KomodoPlatform/atomicDEX-API/blob/mm2.1/mm2src/common/mm_error/mm_error.rs).

    After updating to the latest nightly toolchain this stack trace collection started to work differently. I've created a small project for the demo: https://github.com/artemii235/questionmark_track_caller_try_trait_v2

    cargo +nightly-2021-05-17 run outputs Location { file: "src/main.rs", line: 18, col: 23 } as we expect.

    cargo +nightly-2021-07-18 run outputs Location { file: "/rustc/c7331d65bdbab1187f5a9b8f5b918248678ebdb9/library/core/src/result.rs", line: 1897, col: 27 } - the from_residual implementation that is now used for ? desugaring.

    Is there a way to make the track caller work the same way as it was before? Maybe we can use some workaround in our code?

    Thanks in advance for any help!

  4. cuviper commented on Jul 23, 2021

    @cuviper
    Member

    That's interesting -- maybe Result::from_residual could also have #[track_caller]? But that may bloat a lot of callers in cases that won't ever use the data.

  5. thomaseizinger commented on Jul 23, 2021

    @thomaseizinger
    Contributor

    From the description:

    A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.

    @artemii235 Do you mind opening a separate issue?

  6. artemii235 commented on Jul 23, 2021

    @artemii235

    Do you mind opening a separate issue?

    No objections at all 🙂 I've just created it #87401.

  7. crlf0710 commented on Jul 28, 2021

    @crlf0710
    Member

    May i suggest changing branch method's name to something else? When searching for methods, it's a little not obvious to see Option::branch or Result::branch is not the method one should usually call...

  8. 167 remaining items

  9. valarauca commented on Aug 20, 2026

    @valarauca

    Decide whether to block return types that are FromResidual but not Try

    If this isn't settled (according to OP it isn't). I would like this to not be the case, as it is extremely helpful.

    Why?

    One can setup an either-future (playground link). This permits doing async things, where the construction of the future is seperate from the underlying future.

    In a nutshell it lets you separate:

    • An error occurred preparing the future, a.k.a.: This is a bad RPC/WebRequest/etc.
    • An error occurred during the future, a.k.a.: Network broke, remote server broke, etc.

    A secondary useful effect is related to lifetimes.

    Futures with lifetimes associations carry scheduling & running baggage. While in most cases, especially for non-trivial payloads (say HTTP post requests) passing bodies by reference can be useful. Presently, this is problematic (playground link) as passing your arguments by reference, creates this coupling.

    While the FromResidual & aforementioned either-future (playground link) machinery create a nice escape hatch for this. Permitting you to borrow while constructing/preparing a future, without coupling any errors (or synchronous actions) to the underlying future's execution: example (playground-link). As doing this with async key work (or de-sugared async).

  10. MusicalNinjaDad commented on Aug 24, 2026

    @MusicalNinjaDad
    Contributor

    I've been asked, and agreed, to take the Point-of-Contact role for the related 2026 goal: rust-lang/goals#654
    Feel free to reach out on zulip for any coordination related topics or overlaps with other needs/activities.

  11. added 3 commits that reference this issue on Sep 4, 2026
  12. added a commit that references this issue on Sep 4, 2026
  13. MusicalNinjaDad commented on Sep 6, 2026

    @MusicalNinjaDad
    Contributor

    @rustbot label +I-lang-nominated

    I'm the new project goal owner for rust-lang/goals#654 and am keen to help drive this forwards without stepping on anyone's toes. I'm acutely aware of both how much effort has gone into Try traits so far and how busy those involved are.

    I see the following points which are blocking and probably need more talking than coding in the near future. Before I start actively working them and reaching out to people, I'd like 5-10 minutes with t-lang to check whether there are any concerns:

    Thanks,

  14. added
    P-lang-drag-1Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang
    on Sep 16, 2026
  15. added
    I-lang-radarItems that are on lang's radar and will need eventual work or consideration.
    and removed
    I-lang-nominatedNominated for discussion during a lang team meeting.
    P-lang-drag-1Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang
    on Sep 30, 2026
  16. traviscross commented on Sep 30, 2026

    @traviscross
    Contributor

    We discussed this in the lang call today. Thanks to @MusicalNinjaDad for picking up this important work and for checking in with us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-try_trait_v2Tracking issue for RFC#3058I-lang-radarItems that are on lang's radar and will need eventual work or consideration.S-tracking-design-concernsStatus: There are blocking design concerns.T-langRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions