Skip to content

Commit 0335dc1

Browse files
committed
Make TimingGuard a little safer
1 parent a28b986 commit 0335dc1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/driver/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ impl Drop for TimingGuard {
7373

7474
impl cranelift_codegen::timing::Profiler for MeasuremeProfiler {
7575
fn start_pass(&self, pass: cranelift_codegen::timing::Pass) -> Box<dyn std::any::Any> {
76-
let mut timing_guard =
77-
TimingGuard { profiler: std::mem::ManuallyDrop::new(self.0.clone()), inner: None };
76+
let mut timing_guard = Box::new(TimingGuard {
77+
profiler: std::mem::ManuallyDrop::new(self.0.clone()),
78+
inner: None,
79+
});
7880
timing_guard.inner = Some(
7981
unsafe { &*(&*timing_guard.profiler as &SelfProfilerRef as *const SelfProfilerRef) }
8082
.generic_activity(pass.description()),
8183
);
82-
Box::new(timing_guard)
84+
timing_guard
8385
}
8486
}

0 commit comments

Comments
 (0)