Skip to content

Commit 52f0282

Browse files
authored
Rollup merge of rust-lang#141059 - samueltardieu:push-trvpulpskwwp, r=compiler-errors
HIR: explain in comment why `ExprKind::If` "then" is an `Expr` One could be tempted to replace the "then" `hir::Expr` with kind `hir::ExprKind::Block` by a `hir::Block`. Explain why this would not be a good idea. I've been there. r? `@compiler-errors`
2 parents 6221dde + cf878d8 commit 52f0282

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compiler/rustc_hir/src/hir.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,8 @@ pub enum ExprKind<'hir> {
27442744
///
27452745
/// The "then" expr is always `ExprKind::Block`. If present, the "else" expr is always
27462746
/// `ExprKind::Block` (for `else`) or `ExprKind::If` (for `else if`).
2747+
/// Note that using an `Expr` instead of a `Block` for the "then" part is intentional,
2748+
/// as it simplifies the type coercion machinery.
27472749
If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
27482750
/// A conditionless loop (can be exited with `break`, `continue`, or `return`).
27492751
///

0 commit comments

Comments
 (0)