mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-12 09:57:43 +00:00
Add useful comments on ExprKind::If
variants.
Things that aren't obvious and took me a while to work out.
This commit is contained in:
parent
251cda5e1f
commit
0ea204a5ff
@ -1633,6 +1633,9 @@ pub enum ExprKind {
|
||||
/// An `if` block, with an optional `else` block.
|
||||
///
|
||||
/// `if expr { block } else { expr }`
|
||||
///
|
||||
/// If present, the "else" expr is always `ExprKind::Block` (for `else`) or
|
||||
/// `ExprKind::If` (for `else if`).
|
||||
If(P<Expr>, P<Block>, Option<P<Expr>>),
|
||||
/// A while loop, with an optional label.
|
||||
///
|
||||
|
@ -2730,6 +2730,9 @@ pub enum ExprKind<'hir> {
|
||||
/// An `if` block, with an optional else block.
|
||||
///
|
||||
/// I.e., `if <expr> { <expr> } else { <expr> }`.
|
||||
///
|
||||
/// The "then" expr is always `ExprKind::Block`. If present, the "else" expr is always
|
||||
/// `ExprKind::Block` (for `else`) or `ExprKind::If` (for `else if`).
|
||||
If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
|
||||
/// A conditionless loop (can be exited with `break`, `continue`, or `return`).
|
||||
///
|
||||
|
@ -292,7 +292,10 @@ pub enum ExprKind<'tcx> {
|
||||
If {
|
||||
if_then_scope: region::Scope,
|
||||
cond: ExprId,
|
||||
/// `then` is always `ExprKind::Block`.
|
||||
then: ExprId,
|
||||
/// If present, the `else_opt` expr is always `ExprKind::Block` (for
|
||||
/// `else`) or `ExprKind::If` (for `else if`).
|
||||
else_opt: Option<ExprId>,
|
||||
},
|
||||
/// A function call. Method calls and overloaded operators are converted to plain function calls.
|
||||
|
Loading…
Reference in New Issue
Block a user