Avoid a FieldIdx::from_usize in InstSimplify
This commit is contained in:
@@ -9,7 +9,6 @@ use rustc_middle::ty::layout::ValidityRequirement;
|
||||
use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_span::sym;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::FieldIdx;
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
pub struct InstSimplify;
|
||||
@@ -217,11 +216,11 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
|
||||
&& let Some(place) = operand.place()
|
||||
{
|
||||
let variant = adt_def.non_enum_variant();
|
||||
for (i, field) in variant.fields.iter().enumerate() {
|
||||
for (i, field) in variant.fields.iter_enumerated() {
|
||||
let field_ty = field.ty(self.tcx, args);
|
||||
if field_ty == *cast_ty {
|
||||
let place = place.project_deeper(
|
||||
&[ProjectionElem::Field(FieldIdx::from_usize(i), *cast_ty)],
|
||||
&[ProjectionElem::Field(i, *cast_ty)],
|
||||
self.tcx,
|
||||
);
|
||||
let operand = if operand.is_move() {
|
||||
|
||||
Reference in New Issue
Block a user