@@ -226,6 +226,7 @@ r[destructors.scope.temporary.edition2024]
226226
227227Some examples:
228228
229+ <!-- TODO: edition2024 -->
229230``` rust
230231# struct PrintOnDrop (& 'static str );
231232# impl Drop for PrintOnDrop {
@@ -243,17 +244,25 @@ if PrintOnDrop("If condition").0 == "If condition" {
243244 unreachable! ()
244245};
245246
247+ if let " if let scrutinee" = PrintOnDrop (" if let scrutinee" ). 0 {
248+ PrintOnDrop (" if let consequent" ). 0
249+ // `if let consequent` dropped here
250+ }
251+ // `if let scrutinee` is dropped here
252+ else {
253+ PrintOnDrop (" if let else" ). 0
254+ // `if let else` dropped here
255+ };
256+
246257// Dropped before the first ||
247258(PrintOnDrop (" first operand" ). 0 == ""
248259// Dropped before the )
249260|| PrintOnDrop (" second operand" ). 0 == "" )
250261// Dropped before the ;
251262|| PrintOnDrop (" third operand" ). 0 == "" ;
252263
253- // Dropped at the end of the function, after local variables.
254- // Changing this to a statement containing a return expression would make the
255- // temporary be dropped before the local variables. Binding to a variable
256- // which is then returned would also make the temporary be dropped first.
264+ // Scrutinee is dropped at the end of the function, before local variables
265+ // (because this is the tail expression of the function body block).
257266match PrintOnDrop (" Matched value in final expression" ) {
258267 // Dropped once the condition has been evaluated
259268 _ if PrintOnDrop (" guard condition" ). 0 == "" => (),
0 commit comments