Skip to content

Commit 5621987

Browse files
committed
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). struct S { a: String, b: String, c: String, d: String, e: String, f: String, } Originally reported in #69382 (comment)
1 parent f8ac8fd commit 5621987

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)