Skip to content

Commit f93664e

Browse files
committed
extend doc comment for reachability set computation
1 parent b7dcabe commit f93664e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

compiler/rustc_passes/src/reachable.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
// Finds items that are externally reachable, to determine which items
2-
// need to have their metadata (and possibly their AST) serialized.
3-
// All items that can be referred to through an exported name are
4-
// reachable, and when a reachable thing is inline or generic, it
5-
// makes all other generics or inline functions that it references
6-
// reachable as well.
1+
//! Finds local items that are externally reachable, to determine which items
2+
//! need to have their metadata (and possibly their AST) serialized.
3+
//!
4+
//! This set is *not* transitively closed, i.e., in general the set only contains definitions that
5+
//! can be reached *directly* via an exported name, not private functions that can only be reached
6+
//! transitively.
7+
//!
8+
//! However, there's a catch: if an item is generic or cross-crate inlinable, then it will have its
9+
//! code generated by some downstream crate. Now if that item calls private monomorphic
10+
//! non-cross-crate-inlinable items, then those can be reached by the code generated by the
11+
//! downstream create! Therefore, when a reachable thing is cross-crate inlinable or generic, it
12+
//! makes all other functions that it references reachable as well.
713
814
use hir::def_id::LocalDefIdSet;
915
use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -394,6 +400,7 @@ fn has_custom_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
394400
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
395401
}
396402

403+
/// See module-level doc comment above.
397404
fn reachable_set(tcx: TyCtxt<'_>, (): ()) -> LocalDefIdSet {
398405
let effective_visibilities = &tcx.effective_visibilities(());
399406

0 commit comments

Comments
 (0)