Skip to content

Commit c3b1f54

Browse files
authored
Rollup merge of #107455 - tshepang:better-name, r=wesleywiser
use a more descriptive name I found it hard to distinguish between the two method names. Also, the comment just repeats the `expect` string.
2 parents b3b9383 + f7cc20a commit c3b1f54

File tree

2 files changed

+8
-5
lines changed
  • compiler
    • rustc_middle/src/mir
    • rustc_monomorphize/src/partitioning

2 files changed

+8
-5
lines changed

compiler/rustc_middle/src/mir/mono.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,19 @@ impl<'tcx> CodegenUnit<'tcx> {
318318
base_n::encode(hash, base_n::CASE_INSENSITIVE)
319319
}
320320

321-
pub fn estimate_size(&mut self, tcx: TyCtxt<'tcx>) {
321+
pub fn create_size_estimate(&mut self, tcx: TyCtxt<'tcx>) {
322322
// Estimate the size of a codegen unit as (approximately) the number of MIR
323323
// statements it corresponds to.
324324
self.size_estimate = Some(self.items.keys().map(|mi| mi.size_estimate(tcx)).sum());
325325
}
326326

327327
#[inline]
328+
/// Should only be called if [`create_size_estimate`] has previously been called.
329+
///
330+
/// [`create_size_estimate`]: Self::create_size_estimate
328331
pub fn size_estimate(&self) -> usize {
329-
// Should only be called if `estimate_size` has previously been called.
330-
self.size_estimate.expect("estimate_size must be called before getting a size_estimate")
332+
self.size_estimate
333+
.expect("create_size_estimate must be called before getting a size_estimate")
331334
}
332335

333336
pub fn modify_size_estimate(&mut self, delta: usize) {

compiler/rustc_monomorphize/src/partitioning/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub fn partition<'tcx>(
180180
partitioner.place_root_mono_items(cx, mono_items)
181181
};
182182

183-
initial_partitioning.codegen_units.iter_mut().for_each(|cgu| cgu.estimate_size(tcx));
183+
initial_partitioning.codegen_units.iter_mut().for_each(|cgu| cgu.create_size_estimate(tcx));
184184

185185
debug_dump(tcx, "INITIAL PARTITIONING:", initial_partitioning.codegen_units.iter());
186186

@@ -200,7 +200,7 @@ pub fn partition<'tcx>(
200200
partitioner.place_inlined_mono_items(cx, initial_partitioning)
201201
};
202202

203-
post_inlining.codegen_units.iter_mut().for_each(|cgu| cgu.estimate_size(tcx));
203+
post_inlining.codegen_units.iter_mut().for_each(|cgu| cgu.create_size_estimate(tcx));
204204

205205
debug_dump(tcx, "POST INLINING:", post_inlining.codegen_units.iter());
206206

0 commit comments

Comments
 (0)