Skip to content

Commit d4ea9fa

Browse files
committed
Restore the num_def_ids_untracked public function giving the total number of exported symbols for each crate
Restored underlying num_def_ids_method Update compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Changed name to fit with naming convention Co-authored-by: bjorn3 <[email protected]> Update compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Replace regular doc with Rustdoc comment Co-authored-by: Joshua Nelson <[email protected]> Clarifies third-party use of num_def_ids_untracked
1 parent c4f186f commit d4ea9fa

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,10 @@ impl CrateMetadata {
19311931
self.root.hash
19321932
}
19331933

1934+
fn num_def_ids(&self) -> usize {
1935+
self.root.tables.def_keys.size()
1936+
}
1937+
19341938
fn local_def_id(&self, index: DefIndex) -> DefId {
19351939
DefId { krate: self.cnum, index }
19361940
}

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+7
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,13 @@ impl CStore {
454454
self.get_crate_data(def_id.krate).module_expansion(def_id.index, sess)
455455
}
456456

457+
/// Only public-facing way to traverse all the definitions in a non-local crate.
458+
/// Critically useful for this third-party project: <https://github.com/hacspec/hacspec>.
459+
/// See <https://github.com/rust-lang/rust/pull/85889> for context.
460+
pub fn num_def_ids_untracked(&self, cnum: CrateNum) -> usize {
461+
self.get_crate_data(cnum).num_def_ids()
462+
}
463+
457464
pub fn item_attrs(&self, def_id: DefId, sess: &Session) -> Vec<ast::Attribute> {
458465
self.get_crate_data(def_id.krate).get_item_attrs(def_id.index, sess).collect()
459466
}

0 commit comments

Comments
 (0)