From 6f915056a145628c9f31fefb842c35ec76e7d7bf Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 19 Oct 2021 16:56:47 -0700 Subject: [PATCH] Don't emit a warning for empty rmeta files. --- compiler/rustc_metadata/src/locator.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/rustc_metadata/src/locator.rs b/compiler/rustc_metadata/src/locator.rs index c54ea61060271..bbd30c9327a6c 100644 --- a/compiler/rustc_metadata/src/locator.rs +++ b/compiler/rustc_metadata/src/locator.rs @@ -529,6 +529,15 @@ impl<'a> CrateLocator<'a> { let mut err_data: Option> = None; for (lib, kind) in m { info!("{} reading metadata from: {}", flavor, lib.display()); + if flavor == CrateFlavor::Rmeta && lib.metadata().map_or(false, |m| m.len() == 0) { + // Empty files will cause get_metadata_section to fail. Rmeta + // files can be empty, for example with binaries (which can + // often appear with `cargo check` when checking a library as + // a unittest). We don't want to emit a user-visible warning + // in this case as it is not a real problem. + debug!("skipping empty file"); + continue; + } let (hash, metadata) = match get_metadata_section(self.target, flavor, &lib, self.metadata_loader) { Ok(blob) => {