Do not look for significant drop inside .await expansion

Temporaries created inside the expansion of `.await` will be dropped and need
no checking. Looking inside the expansion will trigger false positives.
This commit is contained in:
Samuel Tardieu 2025-01-11 12:30:17 +01:00
parent ab55d3fc62
commit 0b402baf15
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),
}