Skip to content

Commit da4ec6f

Browse files
committed
Deduplicate tcx.instance_mir(instance) calls in try_instance_mir
1 parent af88f7d commit da4ec6f

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

compiler/rustc_mir_transform/src/inline.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -1027,21 +1027,16 @@ fn try_instance_mir<'tcx>(
10271027
tcx: TyCtxt<'tcx>,
10281028
instance: InstanceDef<'tcx>,
10291029
) -> Result<&'tcx Body<'tcx>, &'static str> {
1030-
match instance {
1031-
ty::InstanceDef::DropGlue(_, Some(ty)) => match ty.kind() {
1032-
ty::Adt(def, args) => {
1033-
let fields = def.all_fields();
1034-
for field in fields {
1035-
let field_ty = field.ty(tcx, args);
1036-
if field_ty.has_param() && field_ty.has_projections() {
1037-
return Err("cannot build drop shim for polymorphic type");
1038-
}
1039-
}
1040-
1041-
Ok(tcx.instance_mir(instance))
1030+
if let ty::InstanceDef::DropGlue(_, Some(ty)) = instance
1031+
&& let ty::Adt(def, args) = ty.kind()
1032+
{
1033+
let fields = def.all_fields();
1034+
for field in fields {
1035+
let field_ty = field.ty(tcx, args);
1036+
if field_ty.has_param() && field_ty.has_projections() {
1037+
return Err("cannot build drop shim for polymorphic type");
10421038
}
1043-
_ => Ok(tcx.instance_mir(instance)),
1044-
},
1045-
_ => Ok(tcx.instance_mir(instance)),
1039+
}
10461040
}
1041+
Ok(tcx.instance_mir(instance))
10471042
}

0 commit comments

Comments
 (0)