-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-try_trait_v2Tracking issue for RFC#3058Tracking issue for RFC#3058S-tracking-design-concernsStatus: There are blocking design concerns.Status: There are blocking design concerns.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
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
- Implement the RFC
- Add the new traits and impls
- Update the desugar in ast lowering
- Fixup all the tests
- Add nice error messages in inference
- Improve perf with enough MIR optimizations
-
Delete the old way after a bootstrap updateRemove theTryV2alias #88223
- Not strictly needed, but a mir-opt to simplify the matches would really help: LLVM/MIR optimizations to simplify the new RFC3058
?desugaring #85133 - Add more detailed documentation about how to implement and use the traits
- Decide whether to block return types that are
FromResidualbut notTry - Fix rustdoc to show the default type parameter on
FromResidualbetter (Issue rustdoc removes Try from <Self as Try>::Residual in std::ops::FromResidual #85454) - Before stabilizing, ensure that all uses of
Infallibleare either fine that way or have been replaced by! - Stabilizing this will allow people to implement
Iterator::try_fold- As part of stabilizing, document implementing try_fold for iterators (perhaps reopen Document implementing
try_foldfor iterators for internal iteration #62606) - Ensure that the default implementations of other things have the desired long-term DAG, since changing them is essentially impossible later. (Specifically, it would be nice to have
foldbe implemented in terms oftry_fold, so that both don't need to be overridden.)
- As part of stabilizing, document implementing try_fold for iterators (perhaps reopen Document implementing
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
From RFC:
- What vocabulary should
Tryuse 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:
- Should there be a trait requirement on residuals of any kind? It's currently possible to accidentally be
FromResidualfrom a type that's never actually produced as a residual (Fix the types in one of theFromResidualimplementations rwf2/Rocket#1645). But that would add more friction for cases not using theFoo<!>pattern, so may not be worth it.- Given the trait in Make
array::{try_from_fn, try_map}andIterator::try_findgeneric overTry#91286, that might look like changing the associatedtype Residual;totype Residual: Residual<Self::Output>;.
- Given the trait in Make
Implementation history
- Basic traits and impls added, Add the
try_trait_v2library basics #84092 - Removing
try_traitfromstdarch, Remove#![feature(try_trait)]from a test stdarch#1142 - Implementing the desugaring, Implement the new desugaring from
try_trait_v2#84767
schneiderfelipe, jablonskim, HarmoGlace, OnlyLys, c410-f3r and 68 moreschneiderfelipe, musjj, migueldamota, ribru17, bbb651 and 1 morejhpratt, dbofmmbt, runiq, stijnh, joseluis and 118 moreeliascarv, schneiderfelipe, musjj, migueldamota, ribru17 and 3 moreeliascarv, schneiderfelipe, hiroki-chen, musjj, migueldamota and 3 more
Metadata
Metadata
Assignees
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-try_trait_v2Tracking issue for RFC#3058Tracking issue for RFC#3058S-tracking-design-concernsStatus: There are blocking design concerns.Status: There are blocking design concerns.T-langRelevant to the language teamRelevant to the language teamT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.