Do not look for significant drop inside .await expansion (#13985)

Temporaries created inside the expansion of `.await` will be dropped and
need no checking. Looking inside the expansion will trigger false
positives.

changelog: [`significant_drop_in_scrutinee`]: do not falsely warn for
temporaries created by `.await` expansion

Fix #13927
This commit is contained in:
dswij 2025-01-14 08:56:39 +00:00 committed by GitHub
commit 8c1ea9fa01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 38 additions and 3 deletions

View file

@ -441,8 +441,9 @@ impl<'tcx> Visitor<'tcx> for SigDropHelper<'_, 'tcx> {
let parent_expr_before = self.parent_expr.replace(ex);
match ex.kind {
// Skip blocks because values in blocks will be dropped as usual.
ExprKind::Block(..) => (),
// Skip blocks because values in blocks will be dropped as usual, and await
// desugaring because temporary insides the future will have been dropped.
ExprKind::Block(..) | ExprKind::Match(_, _, MatchSource::AwaitDesugar) => (),
_ => walk_expr(self, ex),
}