@@ -377,19 +377,6 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
377
377
debug ! ( "is_borrowed_temporary: {:?}" , self . drop_ranges. is_borrowed_temporary( expr) ) ;
378
378
379
379
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
- } ;
393
380
394
381
// Typically, the value produced by an expression is consumed by its parent in some way,
395
382
// 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> {
407
394
// src/test/ui/generator/drop-tracking-parent-expression.rs.
408
395
let scope = if self . drop_ranges . is_borrowed_temporary ( expr)
409
396
|| 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
+ }
413
409
} ) {
414
410
self . rvalue_scopes . temporary_scope ( self . region_scope_tree , expr. hir_id . local_id )
415
411
} else {
0 commit comments