diff options
| author | varkor <github@varkor.com> | 2018-01-19 11:51:48 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-01-19 11:51:48 +0000 |
| commit | 62703cfd26592be8ea641912aa61ecf5d1cbe64f (patch) | |
| tree | a2fe73e0d6759259df1112000a139833cd2147a9 | |
| parent | 5c9a8b504146cc9f755c4e7d73b3693cb781021f (diff) | |
| download | rust-62703cfd26592be8ea641912aa61ecf5d1cbe64f.tar.gz rust-62703cfd26592be8ea641912aa61ecf5d1cbe64f.zip | |
Estimate size of InstanceDef::DropGlue more accurately
Also a little bit of clean up.
| -rw-r--r-- | src/librustc/mir/mono.rs | 6 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 2af2219d267..49e5c0dc21f 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -157,8 +157,7 @@ impl<'tcx> CodegenUnit<'tcx> { pub fn size_estimate(&self) -> usize { // Should only be called if `estimate_size` has previously been called. - assert!(self.size_estimate.is_some()); - self.size_estimate.unwrap() + self.size_estimate.expect("estimate_size must be called before getting a size_estimate") } pub fn modify_size_estimate(&mut self, delta: usize) { @@ -176,7 +175,8 @@ impl<'tcx> HashStable<StableHashingContext<'tcx>> for CodegenUnit<'tcx> { let CodegenUnit { ref items, name, - .. + // The size estimate is not relevant to the hash + size_estimate: _, } = *self; name.hash_stable(hcx, hasher); diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 1d64e7bae91..332afe36010 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2673,11 +2673,12 @@ fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance_def: InstanceDef<'tcx>) -> usize { match instance_def { - InstanceDef::Item(def_id) => { - let mir = tcx.optimized_mir(def_id); + InstanceDef::Item(..) | + InstanceDef::DropGlue(..) => { + let mir = tcx.instance_mir(instance_def); mir.basic_blocks().iter().map(|bb| bb.statements.len()).sum() }, - // Estimate the size of compiler-generated shims to be 1. + // Estimate the size of other compiler-generated shims to be 1. _ => 1 } } |
