Skip to content

Commit

Permalink
Rollup merge of #122526 - Zalathar:thir-expr-docs, r=oli-obk
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr committed Mar 15, 2024
2 parents ee940f8 + cac0b12 commit 7a7b65a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion compiler/rustc_middle/src/thir.rs
Expand Up @@ -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,
Expand All @@ -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>>,
Expand Down

0 comments on commit 7a7b65a

Please sign in to comment.