use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
use rustc_middle::hir::place::ProjectionKind as HirProjectionKind;
use rustc_middle::middle::region;
-use rustc_middle::mir::{self, BinOp, BorrowKind, Field, UnOp};
+use rustc_middle::mir::{self, BinOp, BorrowKind, UnOp};
use rustc_middle::thir::*;
use rustc_middle::ty::adjustment::{
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCast,
self, AdtKind, InlineConstSubsts, InlineConstSubstsParts, ScalarInt, Ty, UpvarSubsts, UserType,
};
use rustc_span::{sym, Span};
-use rustc_target::abi::VariantIdx;
+use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
impl<'tcx> Cx<'tcx> {
pub(crate) fn mirror_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> ExprId {
if self.typeck_results().is_coercion_cast(source.hir_id) {
// Convert the lexpr to a vexpr.
ExprKind::Use { source: self.mirror_expr(source) }
- } else if self.typeck_results().expr_ty(source).is_region_ptr() {
+ } else if self.typeck_results().expr_ty(source).is_ref() {
// Special cased so that we can type check that the element
// type of the source matches the pointed to type of the
// destination.
Res::Def(DefKind::Ctor(_, CtorKind::Fn), ctor_id) => {
Some((adt_def, adt_def.variant_index_with_ctor_id(ctor_id)))
}
- Res::SelfCtor(..) => Some((adt_def, VariantIdx::new(0))),
+ Res::SelfCtor(..) => Some((adt_def, FIRST_VARIANT)),
_ => None,
})
} else {
.iter()
.enumerate()
.map(|(idx, e)| FieldExpr {
- name: Field::new(idx),
+ name: FieldIdx::new(idx),
expr: self.mirror_expr(e),
})
.collect();
debug!("make_mirror_unadjusted: (struct/union) user_ty={:?}", user_ty);
ExprKind::Adt(Box::new(AdtExpr {
adt_def: *adt,
- variant_index: VariantIdx::new(0),
+ variant_index: FIRST_VARIANT,
substs,
user_ty,
fields: self.field_refs(fields),
}
hir::ExprKind::Field(ref source, ..) => ExprKind::Field {
lhs: self.mirror_expr(source),
- variant_index: VariantIdx::new(0),
- name: Field::new(self.typeck_results.field_index(expr.hir_id)),
+ variant_index: FIRST_VARIANT,
+ name: self.typeck_results.field_index(expr.hir_id),
},
hir::ExprKind::Cast(ref source, ref cast_ty) => {
// Check for a user-given type annotation on this `cast`
hir::ExprKind::DropTemps(ref source) => {
ExprKind::Use { source: self.mirror_expr(source) }
}
- hir::ExprKind::Box(ref value) => ExprKind::Box { value: self.mirror_expr(value) },
hir::ExprKind::Array(ref fields) => {
ExprKind::Array { fields: self.mirror_exprs(fields) }
}
HirProjectionKind::Field(field, variant_index) => ExprKind::Field {
lhs: self.thir.exprs.push(captured_place_expr),
variant_index,
- name: Field::new(field as usize),
+ name: field,
},
HirProjectionKind::Index | HirProjectionKind::Subslice => {
// We don't capture these projections, so we can ignore them here
fields
.iter()
.map(|field| FieldExpr {
- name: Field::new(self.typeck_results.field_index(field.hir_id)),
+ name: self.typeck_results.field_index(field.hir_id),
expr: self.mirror_expr(field.expr),
})
.collect()