Skip to content

Commit ab0ab17

Browse files
committed
rdr: add comments indicating that public api hashing must be updated when changing some rmeta encoder functions
1 parent 8adbe4c commit ab0ab17

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
727727

728728
_ = stat!("def-ids", || self.encode_def_ids(hcx));
729729

730+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
730731
let interpret_alloc_index = stat!("interpret-alloc-index", || {
731732
let mut interpret_alloc_index = Vec::new();
732733
let mut n = 0;
@@ -767,6 +768,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
767768
stat!("exportable-items", || self.encode_stable_order_of_exportable_impls());
768769

769770
// Encode exported symbols info. This is prefetched in `encode_metadata`.
771+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
770772
let (exported_non_generic_symbols, exported_generic_symbols) =
771773
stat!("exported-symbols", || {
772774
(
@@ -790,7 +792,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
790792
// `SourceFiles` we actually need to encode.
791793
let source_map =
792794
stat!("source-map", || self.encode_source_map(hcx, &mut public_api_hasher));
795+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
793796
let target_modifiers = stat!("target-modifiers", || self.encode_target_modifiers());
797+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
794798
let denied_partial_mitigations = stat!("denied-partial-mitigations", || self
795799
.encode_enabled_denied_partial_mitigations());
796800

@@ -1759,6 +1763,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17591763
}
17601764
}
17611765

1766+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
17621767
fn encode_externally_implementable_items(&mut self) -> LazyArray<EiiMapEncodedKeyValue> {
17631768
empty_proc_macro!(self);
17641769
let externally_implementable_items = self.tcx.externally_implementable_items(LOCAL_CRATE);
@@ -2080,12 +2085,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
20802085
record!(self.tables.macro_definition[def_id.to_def_id()] <- &*macro_def.body, hcx);
20812086
}
20822087

2088+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
20832089
fn encode_native_libraries(&mut self) -> LazyArray<NativeLib> {
20842090
empty_proc_macro!(self);
20852091
let used_libraries = self.tcx.native_libraries(LOCAL_CRATE);
20862092
self.lazy_array(used_libraries.iter())
20872093
}
20882094

2095+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
20892096
fn encode_foreign_modules(&mut self) -> LazyArray<ForeignModule> {
20902097
empty_proc_macro!(self);
20912098
let foreign_modules = self.tcx.foreign_modules(LOCAL_CRATE);
@@ -2223,6 +2230,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
22232230
}
22242231
}
22252232

2233+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
22262234
fn encode_debugger_visualizers(&mut self) -> LazyArray<DebuggerVisualizerFile> {
22272235
empty_proc_macro!(self);
22282236
self.lazy_array(
@@ -2237,6 +2245,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
22372245
)
22382246
}
22392247

2248+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
22402249
fn encode_crate_deps(&mut self) -> LazyArray<CrateDep> {
22412250
empty_proc_macro!(self);
22422251

@@ -2277,6 +2286,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
22772286
self.lazy_array(lib_features.to_sorted_vec())
22782287
}
22792288

2289+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
22802290
fn encode_stability_implications(&mut self) -> LazyArray<(Symbol, Symbol)> {
22812291
empty_proc_macro!(self);
22822292
let tcx = self.tcx;
@@ -2285,13 +2295,15 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
22852295
self.lazy_array(sorted.into_iter().map(|(k, v)| (*k, *v)))
22862296
}
22872297

2298+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
22882299
fn encode_diagnostic_items(&mut self) -> LazyArray<(Symbol, DefIndex)> {
22892300
empty_proc_macro!(self);
22902301
let tcx = self.tcx;
22912302
let diagnostic_items = &tcx.diagnostic_items(LOCAL_CRATE).name_to_id;
22922303
self.lazy_array(diagnostic_items.iter().map(|(&name, def_id)| (name, def_id.index)))
22932304
}
22942305

2306+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
22952307
fn encode_lang_items(&mut self) -> LazyArray<(DefIndex, LangItem)> {
22962308
empty_proc_macro!(self);
22972309
let lang_items = self.tcx.lang_items().iter();
@@ -2300,12 +2312,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
23002312
}))
23012313
}
23022314

2315+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
23032316
fn encode_lang_items_missing(&mut self) -> LazyArray<LangItem> {
23042317
empty_proc_macro!(self);
23052318
let tcx = self.tcx;
23062319
self.lazy_array(&tcx.lang_items().missing)
23072320
}
23082321

2322+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
23092323
fn encode_stripped_cfg_items(&mut self) -> LazyArray<StrippedCfgItem<DefIndex>> {
23102324
self.lazy_array(
23112325
self.tcx
@@ -2315,12 +2329,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
23152329
)
23162330
}
23172331

2332+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
23182333
fn encode_traits(&mut self) -> LazyArray<DefIndex> {
23192334
empty_proc_macro!(self);
23202335
self.lazy_array(self.tcx.traits(LOCAL_CRATE).iter().map(|def_id| def_id.index))
23212336
}
23222337

23232338
/// Encodes an index, mapping each trait to its (local) implementations.
2339+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
23242340
#[instrument(level = "debug", skip(self, hcx))]
23252341
fn encode_impls(
23262342
&mut self,
@@ -2391,6 +2407,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
23912407
}
23922408

23932409
#[instrument(level = "debug", skip(self))]
2410+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
23942411
fn encode_incoherent_impls(&mut self) -> LazyArray<IncoherentImpls> {
23952412
empty_proc_macro!(self);
23962413
let tcx = self.tcx;
@@ -2409,11 +2426,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
24092426
self.lazy_array(&all_impls)
24102427
}
24112428

2429+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
24122430
fn encode_exportable_items(&mut self) -> LazyArray<DefIndex> {
24132431
empty_proc_macro!(self);
24142432
self.lazy_array(self.tcx.exportable_items(LOCAL_CRATE).iter().map(|def_id| def_id.index))
24152433
}
24162434

2435+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
24172436
fn encode_stable_order_of_exportable_impls(&mut self) -> LazyArray<(DefIndex, usize)> {
24182437
empty_proc_macro!(self);
24192438
let stable_order_of_exportable_impls =
@@ -2438,6 +2457,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
24382457
self.lazy_array(exported_symbols.iter().cloned())
24392458
}
24402459

2460+
// When changed, make sure to update the hashing in `hash_crate_root_public_api`
24412461
fn encode_dylib_dependency_formats(&mut self) -> LazyArray<Option<LinkagePreference>> {
24422462
empty_proc_macro!(self);
24432463
if let Some(arr) = dylib_dependency_formats(self.tcx) {

0 commit comments

Comments
 (0)