@@ -158,6 +158,7 @@ impl<'tcx> Cx<'tcx> {
158158 }
159159
160160 fn make_mirror_unadjusted ( & mut self , expr : & ' tcx hir:: Expr < ' tcx > ) -> Expr < ' tcx > {
161+ let tcx = self . tcx ;
161162 let expr_ty = self . typeck_results ( ) . expr_ty ( expr) ;
162163 let expr_span = expr. span ;
163164 let temp_lifetime = self . region_scope_tree . temporary_scope ( expr. hir_id . local_id ) ;
@@ -196,7 +197,7 @@ impl<'tcx> Cx<'tcx> {
196197
197198 let arg_tys = args. iter ( ) . map ( |e| self . typeck_results ( ) . expr_ty_adjusted ( e) ) ;
198199 let tupled_args = Expr {
199- ty : self . tcx . mk_tup ( arg_tys) ,
200+ ty : tcx. mk_tup ( arg_tys) ,
200201 temp_lifetime,
201202 span : expr. span ,
202203 kind : ExprKind :: Tuple { fields : self . mirror_exprs ( args) } ,
@@ -488,24 +489,24 @@ impl<'tcx> Cx<'tcx> {
488489 out_expr : out_expr. as_ref ( ) . map ( |expr| self . mirror_expr ( expr) ) ,
489490 } ,
490491 hir:: InlineAsmOperand :: Const { ref anon_const } => {
491- let anon_const_def_id = self . tcx . hir ( ) . local_def_id ( anon_const. hir_id ) ;
492+ let anon_const_def_id = tcx. hir ( ) . local_def_id ( anon_const. hir_id ) ;
492493 let value = mir:: ConstantKind :: from_anon_const (
493- self . tcx ,
494+ tcx,
494495 anon_const_def_id,
495496 self . param_env ,
496497 ) ;
497- let span = self . tcx . hir ( ) . span ( anon_const. hir_id ) ;
498+ let span = tcx. hir ( ) . span ( anon_const. hir_id ) ;
498499
499500 InlineAsmOperand :: Const { value, span }
500501 }
501502 hir:: InlineAsmOperand :: SymFn { ref anon_const } => {
502- let anon_const_def_id = self . tcx . hir ( ) . local_def_id ( anon_const. hir_id ) ;
503+ let anon_const_def_id = tcx. hir ( ) . local_def_id ( anon_const. hir_id ) ;
503504 let value = mir:: ConstantKind :: from_anon_const (
504- self . tcx ,
505+ tcx,
505506 anon_const_def_id,
506507 self . param_env ,
507508 ) ;
508- let span = self . tcx . hir ( ) . span ( anon_const. hir_id ) ;
509+ let span = tcx. hir ( ) . span ( anon_const. hir_id ) ;
509510
510511 InlineAsmOperand :: SymFn { value, span }
511512 }
@@ -519,21 +520,16 @@ impl<'tcx> Cx<'tcx> {
519520 } ,
520521
521522 hir:: ExprKind :: ConstBlock ( ref anon_const) => {
522- let tcx = self . tcx ;
523- let local_def_id = tcx. hir ( ) . local_def_id ( anon_const. hir_id ) ;
524- let anon_const_def_id = local_def_id. to_def_id ( ) ;
525-
526- // Need to include the parent substs
527- let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( local_def_id) ;
528- let ty = tcx. typeck ( local_def_id) . node_type ( hir_id) ;
529- let typeck_root_def_id = tcx. typeck_root_def_id ( anon_const_def_id) ;
523+ let ty = self . typeck_results ( ) . node_type ( anon_const. hir_id ) ;
524+ let did = tcx. hir ( ) . local_def_id ( anon_const. hir_id ) . to_def_id ( ) ;
525+ let typeck_root_def_id = tcx. typeck_root_def_id ( did) ;
530526 let parent_substs =
531527 tcx. erase_regions ( InternalSubsts :: identity_for_item ( tcx, typeck_root_def_id) ) ;
532528 let substs =
533529 InlineConstSubsts :: new ( tcx, InlineConstSubstsParts { parent_substs, ty } )
534530 . substs ;
535531
536- ExprKind :: ConstBlock { did : anon_const_def_id , substs }
532+ ExprKind :: ConstBlock { did, substs }
537533 }
538534 // Now comes the rote stuff:
539535 hir:: ExprKind :: Repeat ( ref v, _) => {
@@ -591,7 +587,7 @@ impl<'tcx> Cx<'tcx> {
591587 }
592588 hir:: ExprKind :: Field ( ref source, ..) => ExprKind :: Field {
593589 lhs : self . mirror_expr ( source) ,
594- name : Field :: new ( self . tcx . field_index ( expr. hir_id , self . typeck_results ) ) ,
590+ name : Field :: new ( tcx. field_index ( expr. hir_id , self . typeck_results ) ) ,
595591 } ,
596592 hir:: ExprKind :: Cast ( ref source, ref cast_ty) => {
597593 // Check for a user-given type annotation on this `cast`
@@ -640,7 +636,7 @@ impl<'tcx> Cx<'tcx> {
640636 let ( d, o) = adt_def. discriminant_def_for_variant ( idx) ;
641637 use rustc_middle:: ty:: util:: IntTypeExt ;
642638 let ty = adt_def. repr ( ) . discr_type ( ) ;
643- let ty = ty. to_ty ( self . tcx ( ) ) ;
639+ let ty = ty. to_ty ( tcx) ;
644640 Some ( ( d, o, ty) )
645641 }
646642 _ => None ,
@@ -652,8 +648,7 @@ impl<'tcx> Cx<'tcx> {
652648
653649 let source = if let Some ( ( did, offset, var_ty) ) = var {
654650 let param_env_ty = self . param_env . and ( var_ty) ;
655- let size = self
656- . tcx
651+ let size = tcx
657652 . layout_of ( param_env_ty)
658653 . unwrap_or_else ( |e| {
659654 panic ! ( "could not compute layout for {:?}: {:?}" , param_env_ty, e)
@@ -671,7 +666,7 @@ impl<'tcx> Cx<'tcx> {
671666 Some ( did) => {
672667 // in case we are offsetting from a computed discriminant
673668 // and not the beginning of discriminants (which is always `0`)
674- let substs = InternalSubsts :: identity_for_item ( self . tcx ( ) , did) ;
669+ let substs = InternalSubsts :: identity_for_item ( tcx, did) ;
675670 let kind =
676671 ExprKind :: NamedConst { def_id : did, substs, user_ty : None } ;
677672 let lhs = self . thir . exprs . push ( Expr {
0 commit comments