From 2b60338ee92fbae7e9414dd1bd6661ccd8a7b9da Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 20 Jul 2021 14:18:37 +0200 Subject: Make DefPathHash->DefId panic for if the mapping fails. We only use this mapping for cases where we know that it must succeed. Letting it panic otherwise makes it harder to use the API in unsupported ways. --- compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_metadata/src/rmeta/decoder') diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 4885de103a0..70952d388d5 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -517,10 +517,9 @@ impl CrateStore for CStore { self.get_crate_data(def.krate).def_path_hash(def.index) } - fn def_path_hash_to_def_id(&self, cnum: CrateNum, hash: DefPathHash) -> Option { - self.get_crate_data(cnum) - .def_path_hash_to_def_index(hash) - .map(|index| DefId { krate: cnum, index }) + fn def_path_hash_to_def_id(&self, cnum: CrateNum, hash: DefPathHash) -> DefId { + let def_index = self.get_crate_data(cnum).def_path_hash_to_def_index(hash); + DefId { krate: cnum, index: def_index } } fn expn_hash_to_expn_id(&self, cnum: CrateNum, index_guess: u32, hash: ExpnHash) -> ExpnId { -- cgit 1.4.1-3-g733a5