Skip to content

Commit e6fe4e6

Browse files
authored
Unrolled build for rust-lang#122526
Rollup merge of rust-lang#122526 - Zalathar:thir-expr-docs, r=oli-obk Docs for `thir::ExprKind::Use` and `thir::ExprKind::Let` These docs are based on my own recent investigations; hopefully they're reasonably accurate. `Use` was particularly puzzling to me at first, since the name is not very suggestive, and the old docs were quite cryptic.
2 parents ee03c28 + cac0b12 commit e6fe4e6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/rustc_middle/src/thir.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,13 @@ pub enum ExprKind<'tcx> {
321321
Cast {
322322
source: ExprId,
323323
},
324+
/// Forces its contents to be treated as a value expression, not a place
325+
/// expression. This is inserted in some places where an operation would
326+
/// otherwise be erased completely (e.g. some no-op casts), but we still
327+
/// need to ensure that its operand is treated as a value and not a place.
324328
Use {
325329
source: ExprId,
326-
}, // Use a lexpr to get a vexpr.
330+
},
327331
/// A coercion from `!` to any type.
328332
NeverToAny {
329333
source: ExprId,
@@ -338,6 +342,13 @@ pub enum ExprKind<'tcx> {
338342
Loop {
339343
body: ExprId,
340344
},
345+
/// Special expression representing the `let` part of an `if let` or similar construct
346+
/// (including `if let` guards in match arms, and let-chains formed by `&&`).
347+
///
348+
/// This isn't considered a real expression in surface Rust syntax, so it can
349+
/// only appear in specific situations, such as within the condition of an `if`.
350+
///
351+
/// (Not to be confused with [`StmtKind::Let`], which is a normal `let` statement.)
341352
Let {
342353
expr: ExprId,
343354
pat: Box<Pat<'tcx>>,

0 commit comments

Comments
 (0)