@@ -354,9 +354,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
354354 pub ( crate ) fn as_place (
355355 & mut self ,
356356 mut block : BasicBlock ,
357- expr : & Expr < ' tcx > ,
357+ expr_id : ExprId ,
358358 ) -> 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 ) ) ;
360360 block. and ( place_builder. to_place ( self ) )
361361 }
362362
@@ -365,9 +365,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
365365 pub ( crate ) fn as_place_builder (
366366 & mut self ,
367367 block : BasicBlock ,
368- expr : & Expr < ' tcx > ,
368+ expr_id : ExprId ,
369369 ) -> BlockAnd < PlaceBuilder < ' tcx > > {
370- self . expr_as_place ( block, expr , Mutability :: Mut , None )
370+ self . expr_as_place ( block, expr_id , Mutability :: Mut , None )
371371 }
372372
373373 /// Compile `expr`, yielding a place that we can move from etc.
@@ -378,9 +378,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
378378 pub ( crate ) fn as_read_only_place (
379379 & mut self ,
380380 mut block : BasicBlock ,
381- expr : & Expr < ' tcx > ,
381+ expr_id : ExprId ,
382382 ) -> 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 ) ) ;
384384 block. and ( place_builder. to_place ( self ) )
385385 }
386386
@@ -393,18 +393,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
393393 fn as_read_only_place_builder (
394394 & mut self ,
395395 block : BasicBlock ,
396- expr : & Expr < ' tcx > ,
396+ expr_id : ExprId ,
397397 ) -> BlockAnd < PlaceBuilder < ' tcx > > {
398- self . expr_as_place ( block, expr , Mutability :: Not , None )
398+ self . expr_as_place ( block, expr_id , Mutability :: Not , None )
399399 }
400400
401401 fn expr_as_place (
402402 & mut self ,
403403 mut block : BasicBlock ,
404- expr : & Expr < ' tcx > ,
404+ expr_id : ExprId ,
405405 mutability : Mutability ,
406406 fake_borrow_temps : Option < & mut Vec < Local > > ,
407407 ) -> BlockAnd < PlaceBuilder < ' tcx > > {
408+ let expr = & self . thir [ expr_id] ;
408409 debug ! ( "expr_as_place(block={:?}, expr={:?}, mutability={:?})" , block, expr, mutability) ;
409410
410411 let this = self ;
@@ -413,31 +414,29 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
413414 match expr. kind {
414415 ExprKind :: Scope { region_scope, lint_level, value } => {
415416 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)
417418 } )
418419 }
419420 ExprKind :: Field { lhs, variant_index, name } => {
420- let lhs = & this. thir [ lhs] ;
421+ let lhs_expr = & this. thir [ lhs] ;
421422 let mut place_builder =
422423 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 ( ) {
424425 if adt_def. is_enum ( ) {
425426 place_builder = place_builder. downcast ( * adt_def, variant_index) ;
426427 }
427428 }
428429 block. and ( place_builder. field ( name, expr. ty ) )
429430 }
430431 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, ) ) ;
435434 block. and ( place_builder. deref ( ) )
436435 }
437436 ExprKind :: Index { lhs, index } => this. lower_index_expression (
438437 block,
439- & this . thir [ lhs] ,
440- & this . thir [ index] ,
438+ lhs,
439+ index,
441440 mutability,
442441 fake_borrow_temps,
443442 expr. temp_lifetime ,
@@ -461,12 +460,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
461460
462461 ExprKind :: PlaceTypeAscription { source, ref user_ty } => {
463462 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, )
470464 ) ;
471465 if let Some ( user_ty) = user_ty {
472466 let annotation_index =
@@ -494,9 +488,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
494488 block. and ( place_builder)
495489 }
496490 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+ ) ;
500495 if let Some ( user_ty) = user_ty {
501496 let annotation_index =
502497 this. canonical_user_type_annotations . push ( CanonicalUserTypeAnnotation {
@@ -562,7 +557,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
562557 // these are not places, so we need to make a temporary.
563558 debug_assert ! ( !matches!( Category :: of( & expr. kind) , Some ( Category :: Place ) ) ) ;
564559 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) ) ;
566561 block. and ( PlaceBuilder :: from ( temp) )
567562 }
568563 }
@@ -591,8 +586,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
591586 fn lower_index_expression (
592587 & mut self ,
593588 mut block : BasicBlock ,
594- base : & Expr < ' tcx > ,
595- index : & Expr < ' tcx > ,
589+ base : ExprId ,
590+ index : ExprId ,
596591 mutability : Mutability ,
597592 fake_borrow_temps : Option < & mut Vec < Local > > ,
598593 temp_lifetime : Option < region:: Scope > ,
@@ -609,7 +604,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
609604 // Making this a *fresh* temporary means we do not have to worry about
610605 // the index changing later: Nothing will ever change this temporary.
611606 // 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 ) ) ;
613608
614609 block = self . bounds_check ( block, & base_place, idx, expr_span, source_info) ;
615610
0 commit comments