Skip to content

Commit fa7023d

Browse files
committed
Try to make Queries::finish move out of self
1 parent 80648b8 commit fa7023d

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

compiler/rustc_interface/src/queries.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ impl Compiler {
332332
where
333333
F: for<'tcx> FnOnce(&'tcx Queries<'tcx>) -> T,
334334
{
335-
let mut _timer = None;
336335
let queries = Queries::new(self);
337336
let ret = f(&queries);
338337

@@ -352,11 +351,11 @@ impl Compiler {
352351
.time("serialize_dep_graph", || gcx.enter(rustc_incremental::save_dep_graph));
353352
}
354353

355-
if let Err((path, error)) = queries.finish() {
356-
self.session().emit_err(errors::FailedWritingFile { path: &path, error });
357-
}
358-
359-
_timer = Some(self.session().timer("free_global_ctxt"));
354+
self.session().time("free_global_ctxt", || {
355+
if let Err((path, error)) = queries.finish() {
356+
self.session().emit_err(errors::FailedWritingFile { path: &path, error });
357+
}
358+
});
360359

361360
ret
362361
}

compiler/rustc_metadata/src/rmeta/encoder.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -2252,16 +2252,18 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) {
22522252
// culminating in the `CrateRoot` which points to all of it.
22532253
let root = ecx.encode_crate_root();
22542254

2255+
let file = ecx.opaque.file().try_clone().unwrap();
2256+
let path = ecx.opaque.path().to_owned();
2257+
22552258
// Make sure we report any errors from writing to the file.
22562259
// If we forget this, compilation can succeed with an incomplete rmeta file,
22572260
// causing an ICE when the rmeta file is read by another compilation.
22582261
if let Err((path, err)) = ecx.opaque.finish() {
22592262
tcx.sess.emit_err(FailWriteFile { path: &path, err });
22602263
}
22612264

2262-
let file = ecx.opaque.file();
2263-
if let Err(err) = encode_root_position(file, root.position.get()) {
2264-
tcx.sess.emit_err(FailWriteFile { path: ecx.opaque.path(), err });
2265+
if let Err(err) = encode_root_position(&file, root.position.get()) {
2266+
tcx.sess.emit_err(FailWriteFile { path: &path, err });
22652267
}
22662268

22672269
// Record metadata size for self-profiling

compiler/rustc_middle/src/query/on_disk_cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
866866
}
867867

868868
#[inline]
869-
fn finish(mut self) -> FileEncodeResult {
869+
fn finish(self) -> FileEncodeResult {
870870
self.encoder.finish()
871871
}
872872
}

compiler/rustc_serialize/src/opaque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl FileEncoder {
176176
})
177177
}
178178

179-
pub fn finish(&mut self) -> FileEncodeResult {
179+
pub fn finish(mut self) -> FileEncodeResult {
180180
self.flush();
181181
#[cfg(debug_assertions)]
182182
{

0 commit comments

Comments
 (0)