diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2021-07-20 14:18:37 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2021-09-14 13:56:33 +0200 |
| commit | 2b60338ee92fbae7e9414dd1bd6661ccd8a7b9da (patch) | |
| tree | 216ec1bf1acf3a44da1cff6f545c0c903cedfc4b /compiler/rustc_metadata/src/rmeta/decoder | |
| parent | 5445715c20dbedbe9b14d185937ab1ebcd81118e (diff) | |
| download | rust-2b60338ee92fbae7e9414dd1bd6661ccd8a7b9da.tar.gz rust-2b60338ee92fbae7e9414dd1bd6661ccd8a7b9da.zip | |
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.
Diffstat (limited to 'compiler/rustc_metadata/src/rmeta/decoder')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 7 |
1 files changed, 3 insertions, 4 deletions
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<DefId> { - 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 { |
