Skip to content

Commit

Permalink
Unrolled build for rust-lang#120778
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#120778 - zetanumbers:refactor_try_instance_mir, r=compiler-errors

Deduplicate `tcx.instance_mir(instance)` calls in `try_instance_mir`
  • Loading branch information
rust-timer authored Feb 8, 2024
2 parents c29082f + da4ec6f commit 248fa99
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,21 +1027,16 @@ fn try_instance_mir<'tcx>(
tcx: TyCtxt<'tcx>,
instance: InstanceDef<'tcx>,
) -> Result<&'tcx Body<'tcx>, &'static str> {
match instance {
ty::InstanceDef::DropGlue(_, Some(ty)) => match ty.kind() {
ty::Adt(def, args) => {
let fields = def.all_fields();
for field in fields {
let field_ty = field.ty(tcx, args);
if field_ty.has_param() && field_ty.has_projections() {
return Err("cannot build drop shim for polymorphic type");
}
}

Ok(tcx.instance_mir(instance))
if let ty::InstanceDef::DropGlue(_, Some(ty)) = instance
&& let ty::Adt(def, args) = ty.kind()
{
let fields = def.all_fields();
for field in fields {
let field_ty = field.ty(tcx, args);
if field_ty.has_param() && field_ty.has_projections() {
return Err("cannot build drop shim for polymorphic type");
}
_ => Ok(tcx.instance_mir(instance)),
},
_ => Ok(tcx.instance_mir(instance)),
}
}
Ok(tcx.instance_mir(instance))
}

0 comments on commit 248fa99

Please sign in to comment.