1
Fork 0

Fix panic by checking if CStore has the crate data we want before actually querying it

This commit is contained in:
Guillaume Gomez 2022-06-20 23:31:40 +02:00
parent 987c73158e
commit beb2f364cc
2 changed files with 18 additions and 6 deletions

View file

@ -133,6 +133,10 @@ impl CStore {
CrateNum::new(self.metas.len() - 1)
}
pub fn has_crate_data(&self, cnum: CrateNum) -> bool {
self.metas[cnum].is_some()
}
pub(crate) fn get_crate_data(&self, cnum: CrateNum) -> CrateMetadataRef<'_> {
let cdata = self.metas[cnum]
.as_ref()