Repository navigation
Tracking issue for ? operator (RFC 243, question_mark) #31436
Copy link
Copy link
Closed
Labels
A-error-handlingArea: Error handlingArea: Error handlingB-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.B-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.Blocker: Approved by a merged RFC and implemented but not stabilized.B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.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_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`I-libs-radarLibs issues that are tracked on the team's radar.Libs issues that are tracked on the team's radar.S-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-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
Tracking issue for rust-lang/rfcs#243 and rust-lang/rfcs#1859.
See also the related tracking issue for try_trait_v2, #84277 (rust-lang/rfcs#3058)
"Try Blocks" (try { ... }) were previously tracked here, but moved to #154391
For heterogeneous try bikeshed MyType blocks, see #149488
Implementation concerns:
-
?operator that is roughly equivalent totry!- implement the?operator #31954 -
try { ... }expression - implementcatchexpressions #39849- resolve
do catch { ... }syntax question - resolve whether catch blocks should "wrap" result value (first addressed in
catchblocks are notOk-wrapping their value #41414, now being settled anew in ResolvingOk-wrapping fortryblocks #70941) - Add a test confirming that it's an
ExprWithBlock, so works in a match arm without a comma - Address issues with type inference (
try { expr? }?currently requires an explicit type annotation somewhere).
- resolve
- settle design of the
Trytrait (extend?to operate over other types rfcs#1859)- implement new
Trytrait (in place ofCarrier) and convert?to use it (Lower?toTryinstead ofCarrier#42275) - add impls for
Optionand so forth, and a suitable family of tests (Impl Try for Option #42526) - improve error messages as described in the RFC (Improve
?error messages per RFC 1859 #35946)
- implement new
- reserve
tryin new edition - block
try{}catch(or other following idents) to leave design space open for the future, and point people to how to do what they want withmatchinstead
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-error-handlingArea: Error handlingArea: Error handlingB-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.B-RFC-implementedBlocker: Approved by a merged RFC and implemented but not stabilized.Blocker: Approved by a merged RFC and implemented but not stabilized.B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.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_blocks`#![feature(try_blocks)]``#![feature(try_blocks)]`I-libs-radarLibs issues that are tracked on the team's radar.Libs issues that are tracked on the team's radar.S-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-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Activity
reem commentedon Feb 5, 2016
The accompanying RFC discusses a desugaring based on labeled return/break, are we getting that too or will there just be special treatment for
?andcatchin the compiler?EDIT: I think labeled return/break is an excellent idea separate from
?andcatch, so if the answer is no I will probably open a separate RFC for it.nikomatsakis commentedon Feb 5, 2016
Labeled return/break is purely for explanatory purposes.
On Fri, Feb 5, 2016 at 3:56 PM, Jonathan Reem notifications@github.com
wrote:
glaebhoerl commentedon Feb 5, 2016
Another unresolved question we have to resolve before stabilizing is what the contract which
impls ofIntohave to obey should be -- or whetherIntois even the right trait to use for the error-upcasting here. (Perhaps this should be another checklist item?)petrochenkov commentedon Feb 5, 2016
@reem
Please do!
thepowersgang commentedon Feb 6, 2016
On the subject of the
Carriertrait, here is a gist example of such a trait I wrote back early in the RFC process.https://gist.github.com/thepowersgang/f0de63db1746114266d3
petrochenkov commentedon Feb 6, 2016
How this is treated during parsing?
eddyb commentedon Feb 6, 2016
@petrochenkov Well, the definition couldn't affect parsing, but I think we still have a lookahead rule, based on the second token after
{,:in this case, so it should still be parsed as a struct literal.petrochenkov commentedon Feb 6, 2016
Also
+ rust-lang/rfcs#306 if (when!) implemented.
It seems like there are no conflicts besides struct literals.
Given the examples above I'm for the simplest solution (as usual) - always treat
catch {in expression positions as start of acatchblock. Nobody calls their structurescatchanyway.durka commentedon Feb 6, 2016
It would be easier if a keyword was used instead of
catch.bluss commentedon Feb 6, 2016
This is the keywords list: http://doc.rust-lang.org/nightly/grammar.html#keywords
durka commentedon Feb 6, 2016
@bluss yeah, I admit none of them are great...
overrideseems like the only one that is close. Or we could usedo, heh. Or a combination, though I don't see any great ones immediately.do catch?501 remaining items
Rollup merge of rust-lang#148725 - scottmcm:experiment-new-try-block-…
Rollup merge of rust-lang#153445 - ia0:overflow_try, r=ytmimi
Rollup merge of rust-lang#153445 - ia0:overflow_try, r=ytmimi
Rollup merge of rust-lang#153445 - ia0:overflow_try, r=ytmimi
Rollup merge of rust-lang#153445 - ia0:overflow_try, r=ytmimi
Unrolled build for #153445
Rollup merge of #153445 - ia0:overflow_try, r=ytmimi
scottmcm commentedon Mar 26, 2026
Thanks for over 10 years (😮) of discussion on this issue! With the new RFC (rust-lang/rfcs#3721) merged, I'm going to move the
try { ... }tracking to a new issue, #154391(Not closing now as the tracking issue number in source needs an update first.)
[-]Tracking issue for `?` operator and `try` blocks (RFC 243, `question_mark` & `try_blocks` features)[/-][+]Tracking issue for `?` operator (RFC 243, `question_mark`)[/+]Rollup merge of rust-lang#154409 - scottmcm:change-try-tracking, r=Ta…
Rollup merge of rust-lang#154409 - scottmcm:change-try-tracking, r=Ta…
Rollup merge of #154409 - scottmcm:change-try-tracking, r=TaKO8Ki
Rollup merge of #153445 - ia0:overflow_try, r=ytmimi