@@ -354,9 +354,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
354
354
pub ( crate ) fn as_place (
355
355
& mut self ,
356
356
mut block : BasicBlock ,
357
- expr : & Expr < ' tcx > ,
357
+ expr_id : ExprId ,
358
358
) -> BlockAnd < Place < ' tcx > > {
359
- let place_builder = unpack ! ( block = self . as_place_builder( block, expr ) ) ;
359
+ let place_builder = unpack ! ( block = self . as_place_builder( block, expr_id ) ) ;
360
360
block. and ( place_builder. to_place ( self ) )
361
361
}
362
362
@@ -365,9 +365,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
365
365
pub ( crate ) fn as_place_builder (
366
366
& mut self ,
367
367
block : BasicBlock ,
368
- expr : & Expr < ' tcx > ,
368
+ expr_id : ExprId ,
369
369
) -> BlockAnd < PlaceBuilder < ' tcx > > {
370
- self . expr_as_place ( block, expr , Mutability :: Mut , None )
370
+ self . expr_as_place ( block, expr_id , Mutability :: Mut , None )
371
371
}
372
372
373
373
/// Compile `expr`, yielding a place that we can move from etc.
@@ -378,9 +378,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
378
378
pub ( crate ) fn as_read_only_place (
379
379
& mut self ,
380
380
mut block : BasicBlock ,
381
- expr : & Expr < ' tcx > ,
381
+ expr_id : ExprId ,
382
382
) -> BlockAnd < Place < ' tcx > > {
383
- let place_builder = unpack ! ( block = self . as_read_only_place_builder( block, expr ) ) ;
383
+ let place_builder = unpack ! ( block = self . as_read_only_place_builder( block, expr_id ) ) ;
384
384
block. and ( place_builder. to_place ( self ) )
385
385
}
386
386
@@ -393,18 +393,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
393
393
fn as_read_only_place_builder (
394
394
& mut self ,
395
395
block : BasicBlock ,
396
- expr : & Expr < ' tcx > ,
396
+ expr_id : ExprId ,
397
397
) -> BlockAnd < PlaceBuilder < ' tcx > > {
398
- self . expr_as_place ( block, expr , Mutability :: Not , None )
398
+ self . expr_as_place ( block, expr_id , Mutability :: Not , None )
399
399
}
400
400
401
401
fn expr_as_place (
402
402
& mut self ,
403
403
mut block : BasicBlock ,
404
- expr : & Expr < ' tcx > ,
404
+ expr_id : ExprId ,
405
405
mutability : Mutability ,
406
406
fake_borrow_temps : Option < & mut Vec < Local > > ,
407
407
) -> BlockAnd < PlaceBuilder < ' tcx > > {
408
+ let expr = & self . thir [ expr_id] ;
408
409
debug ! ( "expr_as_place(block={:?}, expr={:?}, mutability={:?})" , block, expr, mutability) ;
409
410
410
411
let this = self ;
@@ -413,31 +414,29 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
413
414
match expr. kind {
414
415
ExprKind :: Scope { region_scope, lint_level, value } => {
415
416
this. in_scope ( ( region_scope, source_info) , lint_level, |this| {
416
- this. expr_as_place ( block, & this . thir [ value] , mutability, fake_borrow_temps)
417
+ this. expr_as_place ( block, value, mutability, fake_borrow_temps)
417
418
} )
418
419
}
419
420
ExprKind :: Field { lhs, variant_index, name } => {
420
- let lhs = & this. thir [ lhs] ;
421
+ let lhs_expr = & this. thir [ lhs] ;
421
422
let mut place_builder =
422
423
unpack ! ( block = this. expr_as_place( block, lhs, mutability, fake_borrow_temps, ) ) ;
423
- if let ty:: Adt ( adt_def, _) = lhs . ty . kind ( ) {
424
+ if let ty:: Adt ( adt_def, _) = lhs_expr . ty . kind ( ) {
424
425
if adt_def. is_enum ( ) {
425
426
place_builder = place_builder. downcast ( * adt_def, variant_index) ;
426
427
}
427
428
}
428
429
block. and ( place_builder. field ( name, expr. ty ) )
429
430
}
430
431
ExprKind :: Deref { arg } => {
431
- let place_builder = unpack ! (
432
- block =
433
- this. expr_as_place( block, & this. thir[ arg] , mutability, fake_borrow_temps, )
434
- ) ;
432
+ let place_builder =
433
+ unpack ! ( block = this. expr_as_place( block, arg, mutability, fake_borrow_temps, ) ) ;
435
434
block. and ( place_builder. deref ( ) )
436
435
}
437
436
ExprKind :: Index { lhs, index } => this. lower_index_expression (
438
437
block,
439
- & this . thir [ lhs] ,
440
- & this . thir [ index] ,
438
+ lhs,
439
+ index,
441
440
mutability,
442
441
fake_borrow_temps,
443
442
expr. temp_lifetime ,
@@ -461,12 +460,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
461
460
462
461
ExprKind :: PlaceTypeAscription { source, ref user_ty } => {
463
462
let place_builder = unpack ! (
464
- block = this. expr_as_place(
465
- block,
466
- & this. thir[ source] ,
467
- mutability,
468
- fake_borrow_temps,
469
- )
463
+ block = this. expr_as_place( block, source, mutability, fake_borrow_temps, )
470
464
) ;
471
465
if let Some ( user_ty) = user_ty {
472
466
let annotation_index =
@@ -494,9 +488,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
494
488
block. and ( place_builder)
495
489
}
496
490
ExprKind :: ValueTypeAscription { source, ref user_ty } => {
497
- let source = & this. thir [ source] ;
498
- let temp =
499
- unpack ! ( block = this. as_temp( block, source. temp_lifetime, source, mutability) ) ;
491
+ let source_expr = & this. thir [ source] ;
492
+ let temp = unpack ! (
493
+ block = this. as_temp( block, source_expr. temp_lifetime, source, mutability)
494
+ ) ;
500
495
if let Some ( user_ty) = user_ty {
501
496
let annotation_index =
502
497
this. canonical_user_type_annotations . push ( CanonicalUserTypeAnnotation {
@@ -562,7 +557,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
562
557
// these are not places, so we need to make a temporary.
563
558
debug_assert ! ( !matches!( Category :: of( & expr. kind) , Some ( Category :: Place ) ) ) ;
564
559
let temp =
565
- unpack ! ( block = this. as_temp( block, expr. temp_lifetime, expr , mutability) ) ;
560
+ unpack ! ( block = this. as_temp( block, expr. temp_lifetime, expr_id , mutability) ) ;
566
561
block. and ( PlaceBuilder :: from ( temp) )
567
562
}
568
563
}
@@ -591,8 +586,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
591
586
fn lower_index_expression (
592
587
& mut self ,
593
588
mut block : BasicBlock ,
594
- base : & Expr < ' tcx > ,
595
- index : & Expr < ' tcx > ,
589
+ base : ExprId ,
590
+ index : ExprId ,
596
591
mutability : Mutability ,
597
592
fake_borrow_temps : Option < & mut Vec < Local > > ,
598
593
temp_lifetime : Option < region:: Scope > ,
@@ -609,7 +604,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
609
604
// Making this a *fresh* temporary means we do not have to worry about
610
605
// the index changing later: Nothing will ever change this temporary.
611
606
// The "retagging" transformation (for Stacked Borrows) relies on this.
612
- let idx = unpack ! ( block = self . as_temp( block, temp_lifetime, index, Mutability :: Not , ) ) ;
607
+ let idx = unpack ! ( block = self . as_temp( block, temp_lifetime, index, Mutability :: Not ) ) ;
613
608
614
609
block = self . bounds_check ( block, & base_place, idx, expr_span, source_info) ;
615
610
0 commit comments