Skip to content

Commit 40ebd07

Browse files
committed
Auto merge of #90072 - ehuss:empty-rmeta-no-warn, r=Mark-Simulacrum
Don't emit a warning for empty rmeta files. This avoids displaying a warning when attempting to load an empty rmeta file. Warnings were enabled via #89634 which can cause a lot of noise (for example, running `./x.py check`). rustc generates empty rmeta files for things like binaries, which can happen when checking libraries as unittests. Closes #89795
2 parents 4626184 + 6f91505 commit 40ebd07

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: compiler/rustc_metadata/src/locator.rs

+9
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,15 @@ impl<'a> CrateLocator<'a> {
529529
let mut err_data: Option<Vec<PathBuf>> = None;
530530
for (lib, kind) in m {
531531
info!("{} reading metadata from: {}", flavor, lib.display());
532+
if flavor == CrateFlavor::Rmeta && lib.metadata().map_or(false, |m| m.len() == 0) {
533+
// Empty files will cause get_metadata_section to fail. Rmeta
534+
// files can be empty, for example with binaries (which can
535+
// often appear with `cargo check` when checking a library as
536+
// a unittest). We don't want to emit a user-visible warning
537+
// in this case as it is not a real problem.
538+
debug!("skipping empty file");
539+
continue;
540+
}
532541
let (hash, metadata) =
533542
match get_metadata_section(self.target, flavor, &lib, self.metadata_loader) {
534543
Ok(blob) => {

0 commit comments

Comments
 (0)