diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-03-15 12:33:32 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-03-15 13:11:00 +1100 |
| commit | cac0b121b6ab5a3a2f34cd458d755bda503e619b (patch) | |
| tree | 87ddddb506ad00cb24618d81793df2deaaca4088 | |
| parent | c2901f543577af99b9cb708f5c0d28525eb7f08f (diff) | |
| download | rust-cac0b121b6ab5a3a2f34cd458d755bda503e619b.tar.gz rust-cac0b121b6ab5a3a2f34cd458d755bda503e619b.zip | |
Docs for `thir::ExprKind::Use` and `thir::ExprKind::Let`
| -rw-r--r-- | compiler/rustc_middle/src/thir.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 74b47d8b04e..96a61883cc1 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -321,9 +321,13 @@ pub enum ExprKind<'tcx> { Cast { source: ExprId, }, + /// Forces its contents to be treated as a value expression, not a place + /// expression. This is inserted in some places where an operation would + /// otherwise be erased completely (e.g. some no-op casts), but we still + /// need to ensure that its operand is treated as a value and not a place. Use { source: ExprId, - }, // Use a lexpr to get a vexpr. + }, /// A coercion from `!` to any type. NeverToAny { source: ExprId, @@ -338,6 +342,13 @@ pub enum ExprKind<'tcx> { Loop { body: ExprId, }, + /// Special expression representing the `let` part of an `if let` or similar construct + /// (including `if let` guards in match arms, and let-chains formed by `&&`). + /// + /// This isn't considered a real expression in surface Rust syntax, so it can + /// only appear in specific situations, such as within the condition of an `if`. + /// + /// (Not to be confused with [`StmtKind::Let`], which is a normal `let` statement.) Let { expr: ExprId, pat: Box<Pat<'tcx>>, |
