@@ -158,6 +158,7 @@ impl<'tcx> Cx<'tcx> {
158
158
}
159
159
160
160
fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx> {
161
+ let tcx = self.tcx;
161
162
let expr_ty = self.typeck_results().expr_ty(expr);
162
163
let expr_span = expr.span;
163
164
let temp_lifetime = self.region_scope_tree.temporary_scope(expr.hir_id.local_id);
@@ -196,7 +197,7 @@ impl<'tcx> Cx<'tcx> {
196
197
197
198
let arg_tys = args.iter().map(|e| self.typeck_results().expr_ty_adjusted(e));
198
199
let tupled_args = Expr {
199
- ty: self. tcx.mk_tup(arg_tys),
200
+ ty: tcx.mk_tup(arg_tys),
200
201
temp_lifetime,
201
202
span: expr.span,
202
203
kind: ExprKind::Tuple { fields: self.mirror_exprs(args) },
@@ -488,24 +489,24 @@ impl<'tcx> Cx<'tcx> {
488
489
out_expr: out_expr.as_ref().map(|expr| self.mirror_expr(expr)),
489
490
},
490
491
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);
492
493
let value = mir::ConstantKind::from_anon_const(
493
- self. tcx,
494
+ tcx,
494
495
anon_const_def_id,
495
496
self.param_env,
496
497
);
497
- let span = self. tcx.hir().span(anon_const.hir_id);
498
+ let span = tcx.hir().span(anon_const.hir_id);
498
499
499
500
InlineAsmOperand::Const { value, span }
500
501
}
501
502
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);
503
504
let value = mir::ConstantKind::from_anon_const(
504
- self. tcx,
505
+ tcx,
505
506
anon_const_def_id,
506
507
self.param_env,
507
508
);
508
- let span = self. tcx.hir().span(anon_const.hir_id);
509
+ let span = tcx.hir().span(anon_const.hir_id);
509
510
510
511
InlineAsmOperand::SymFn { value, span }
511
512
}
@@ -519,21 +520,16 @@ impl<'tcx> Cx<'tcx> {
519
520
},
520
521
521
522
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);
530
526
let parent_substs =
531
527
tcx.erase_regions(InternalSubsts::identity_for_item(tcx, typeck_root_def_id));
532
528
let substs =
533
529
InlineConstSubsts::new(tcx, InlineConstSubstsParts { parent_substs, ty })
534
530
.substs;
535
531
536
- ExprKind::ConstBlock { did: anon_const_def_id , substs }
532
+ ExprKind::ConstBlock { did, substs }
537
533
}
538
534
// Now comes the rote stuff:
539
535
hir::ExprKind::Repeat(ref v, _) => {
@@ -591,7 +587,7 @@ impl<'tcx> Cx<'tcx> {
591
587
}
592
588
hir::ExprKind::Field(ref source, ..) => ExprKind::Field {
593
589
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)),
595
591
},
596
592
hir::ExprKind::Cast(ref source, ref cast_ty) => {
597
593
// Check for a user-given type annotation on this `cast`
@@ -640,7 +636,7 @@ impl<'tcx> Cx<'tcx> {
640
636
let (d, o) = adt_def.discriminant_def_for_variant(idx);
641
637
use rustc_middle::ty::util::IntTypeExt;
642
638
let ty = adt_def.repr().discr_type();
643
- let ty = ty.to_ty(self. tcx() );
639
+ let ty = ty.to_ty(tcx);
644
640
Some((d, o, ty))
645
641
}
646
642
_ => None,
@@ -652,8 +648,7 @@ impl<'tcx> Cx<'tcx> {
652
648
653
649
let source = if let Some((did, offset, var_ty)) = var {
654
650
let param_env_ty = self.param_env.and(var_ty);
655
- let size = self
656
- .tcx
651
+ let size = tcx
657
652
.layout_of(param_env_ty)
658
653
.unwrap_or_else(|e| {
659
654
panic!("could not compute layout for {:?}: {:?}", param_env_ty, e)
@@ -671,7 +666,7 @@ impl<'tcx> Cx<'tcx> {
671
666
Some(did) => {
672
667
// in case we are offsetting from a computed discriminant
673
668
// 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);
675
670
let kind =
676
671
ExprKind::NamedConst { def_id: did, substs, user_ty: None };
677
672
let lhs = self.thir.exprs.push(Expr {
0 commit comments