Skip to content

Commit 7a9ff74

Browse files
committed
Auto merge of #86777 - tmiasko:estimate-terminators, r=estebank
Include terminators in instance size estimate For example, drop glue generated for struct below, doesn't have any statements, only terminators. Previously it received an estimate of 0, the new estimate is 13 (6+5 drop terminators, +1 resume, +1 return). ```rust struct S { a: String, b: String, c: String, d: String, e: String, f: String, } ``` Originally reported in rust-lang/rust#69382 (comment)
2 parents 56dee7c + 5621987 commit 7a9ff74

File tree

1 file changed

+1
-1
lines changed
  • compiler/rustc_ty_utils/src

1 file changed

+1
-1
lines changed

compiler/rustc_ty_utils/src/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ fn instance_def_size_estimate<'tcx>(
402402
match instance_def {
403403
InstanceDef::Item(..) | InstanceDef::DropGlue(..) => {
404404
let mir = tcx.instance_mir(instance_def);
405-
mir.basic_blocks().iter().map(|bb| bb.statements.len()).sum()
405+
mir.basic_blocks().iter().map(|bb| bb.statements.len() + 1).sum()
406406
}
407407
// Estimate the size of other compiler-generated shims to be 1.
408408
_ => 1,

0 commit comments

Comments
 (0)