Skip to content

Commit 134de38

Browse files
nit: Inline may_need_drop
1 parent 5b06898 commit 134de38

File tree

1 file changed

+12
-16
lines changed
  • compiler/rustc_hir_typeck/src/generator_interior

1 file changed

+12
-16
lines changed

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

+12-16
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,6 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
377377
debug!("is_borrowed_temporary: {:?}", self.drop_ranges.is_borrowed_temporary(expr));
378378

379379
let ty = self.fcx.typeck_results.borrow().expr_ty_adjusted_opt(expr);
380-
let may_need_drop = |ty: Ty<'tcx>| {
381-
// Avoid ICEs in needs_drop.
382-
let ty = self.fcx.resolve_vars_if_possible(ty);
383-
let ty = self.fcx.tcx.erase_regions(ty);
384-
if ty.needs_infer() {
385-
self.fcx
386-
.tcx
387-
.sess
388-
.delay_span_bug(expr.span, &format!("inference variables in {ty}"));
389-
return true;
390-
}
391-
ty.needs_drop(self.fcx.tcx, self.fcx.param_env)
392-
};
393380

394381
// Typically, the value produced by an expression is consumed by its parent in some way,
395382
// so we only have to check if the parent contains a yield (note that the parent may, for
@@ -407,9 +394,18 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
407394
// src/test/ui/generator/drop-tracking-parent-expression.rs.
408395
let scope = if self.drop_ranges.is_borrowed_temporary(expr)
409396
|| ty.map_or(true, |ty| {
410-
let needs_drop = may_need_drop(ty);
411-
debug!(?needs_drop, ?ty);
412-
needs_drop
397+
// Avoid ICEs in needs_drop.
398+
let ty = self.fcx.resolve_vars_if_possible(ty);
399+
let ty = self.fcx.tcx.erase_regions(ty);
400+
if ty.needs_infer() {
401+
self.fcx
402+
.tcx
403+
.sess
404+
.delay_span_bug(expr.span, &format!("inference variables in {ty}"));
405+
true
406+
} else {
407+
ty.needs_drop(self.fcx.tcx, self.fcx.param_env)
408+
}
413409
}) {
414410
self.rvalue_scopes.temporary_scope(self.region_scope_tree, expr.hir_id.local_id)
415411
} else {

0 commit comments

Comments
 (0)