diff options
| author | Michael Goulet <michael@errs.io> | 2025-02-23 01:09:51 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-02-24 18:31:50 +0000 |
| commit | bad8e98c7d0ed217b58362e61ae4357e5344d995 (patch) | |
| tree | 1e0c6023ac65a70bbc6442b8fbb654352546bd86 /compiler/rustc_lint/src/if_let_rescope.rs | |
| parent | 2797936f6dcd29777f236a5d966d487a7f4cbbb3 (diff) | |
| download | rust-bad8e98c7d0ed217b58362e61ae4357e5344d995.tar.gz rust-bad8e98c7d0ed217b58362e61ae4357e5344d995.zip | |
Consider lvalues of field and index as possibly temporary places
Diffstat (limited to 'compiler/rustc_lint/src/if_let_rescope.rs')
| -rw-r--r-- | compiler/rustc_lint/src/if_let_rescope.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 55d900e0319..23f037f3692 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -436,6 +436,14 @@ impl<'tcx> Visitor<'tcx> for FindSignificantDropper<'_, 'tcx> { self.check_promoted_temp_with_drop(expr)?; intravisit::walk_expr(self, expr) } + // `(Drop, ()).1` introduces a temporary and then moves out of + // part of it, therefore we should check it for temporaries. + // FIXME: This may have false positives if we move the part + // that actually has drop, but oh well. + hir::ExprKind::Index(expr, _, _) | hir::ExprKind::Field(expr, _) => { + self.check_promoted_temp_with_drop(expr)?; + intravisit::walk_expr(self, expr) + } // If always introduces a temporary terminating scope for its cond and arms, // so don't visit them. hir::ExprKind::If(..) => ControlFlow::Continue(()), |
