Rollup merge of #80372 - jyn514:fix-panics, r=Manishearth

Don't panic when an external crate can't be resolved

This isn't actually a bug, it can occur when rustdoc tries to resolve a
crate that isn't used in the main code.

Fixes #72381.

r? `@kinnison` if you have time, otherwise `@Manishearth`
This commit is contained in:
Yuki Okushi
2021-01-08 11:11:41 +09:00
committed by GitHub
3 changed files with 24 additions and 5 deletions

View File

@@ -434,16 +434,15 @@ crate fn create_resolver<'a>(
sess.time("load_extern_crates", || {
for extern_name in &extern_names {
debug!("loading extern crate {}", extern_name);
resolver
if let Err(()) = resolver
.resolve_str_path_error(
DUMMY_SP,
extern_name,
TypeNS,
LocalDefId { local_def_index: CRATE_DEF_INDEX }.to_def_id(),
)
.unwrap_or_else(|()| {
panic!("Unable to resolve external crate {}", extern_name)
});
) {
warn!("unable to resolve external crate {} (do you have an unused `--extern` crate?)", extern_name)
}
}
});
});