-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Semicolon after diverging try operator shouldn't matter #106357
Copy link
Copy link
Closed as not planned
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.F-never_type`#![feature(never_type)]``#![feature(never_type)]`I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-langRelevant to the language teamRelevant to the language teamT-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.
Metadata
Metadata
Assignees
Labels
C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.F-never_type`#![feature(never_type)]``#![feature(never_type)]`I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.T-langRelevant to the language teamRelevant to the language teamT-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Originally mentioned in this comment: #96373 (comment)
Essentially, semicolons after other diverging expressions are allowed. For example:
Here, the compiler is clever enough to note that because
return Err(1)always diverges, adding a semicolon after doesn't matter. However, the below code which is equivalent to this does not work properly:Here's a playground link containing the above two examples: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=af894bab48348897a421a9402856b71f
The exact compiler error: