Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch blocks can produce non-Try values #43818

Closed
scottmcm opened this issue Aug 12, 2017 · 1 comment
Closed

catch blocks can produce non-Try values #43818

scottmcm opened this issue Aug 12, 2017 · 1 comment
Labels
C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
Member

scottmcm commented Aug 12, 2017

This works today, and I think it's not supposed to:

let x: i32 = do catch { 4 };

Repro: https://play.rust-lang.org/?gist=0c5b165abf4c06ff5821550986db4531&version=nightly

The value that comes out of a catch seems like it's supposed to only be something that's Try, since otherwise you cannot use ? inside the catch. (Magic ok-wrapping could make the block itself legal, but it'd still need to return some impl Try<Ok=i32>, not a raw i32.)

cc catch tracking issue: #31436

@kennytm
Copy link
Member

kennytm commented Aug 12, 2017

cc #41414.

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Aug 13, 2017
bors added a commit that referenced this issue Apr 12, 2018
Add ok-wrapping to catch blocks, per RFC

Updates the `catch{}` lowering to wrap the result in `Try::from_ok`.

r? @nikomatsakis

Fixes #41414
Fixes #43818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-needs-decision Issue: In need of a decision. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants