rust/compiler/rustc_parse/src
bors c2a408840a Auto merge of #87688 - camsteffen:let-else, r=cjgillot
Introduce `let...else`

Tracking issue: #87335

The trickiest part for me was enforcing the diverging else block with clear diagnostics. Perhaps the obvious solution is to expand to `let _: ! = ..`, but I decided against this because, when a "mismatched type" error is found in typeck, there is no way to trace where in the HIR the expected type originated, AFAICT. In order to pass down this information, I believe we should introduce `Expectation::LetElseNever(HirId)` or maybe add `HirId` to `Expectation::HasType`, but I left that as a future enhancement. For now, I simply assert that the block is `!` with a custom `ObligationCauseCode`, and I think this is clear enough, at least to start. The downside here is that the error points at the entire block rather than the specific expression with the wrong type. I left a todo to this effect.

Overall, I believe this PR is feature-complete with regard to the RFC.
2021-09-01 01:02:42 +00:00
..
lexer Warn when an escaped newline skips multiple lines 2021-08-11 11:35:08 +02:00
parser Auto merge of #87688 - camsteffen:let-else, r=cjgillot 2021-09-01 01:02:42 +00:00
lib.rs Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
validate_attr.rs Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00