Skip to content

Commit

Permalink
extend doc comment for reachability set computation
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 20, 2024
1 parent b7dcabe commit f93664e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions compiler/rustc_passes/src/reachable.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
// Finds items that are externally reachable, to determine which items
// need to have their metadata (and possibly their AST) serialized.
// All items that can be referred to through an exported name are
// reachable, and when a reachable thing is inline or generic, it
// makes all other generics or inline functions that it references
// reachable as well.
//! Finds local items that are externally reachable, to determine which items
//! need to have their metadata (and possibly their AST) serialized.
//!
//! This set is *not* transitively closed, i.e., in general the set only contains definitions that
//! can be reached *directly* via an exported name, not private functions that can only be reached
//! transitively.
//!
//! However, there's a catch: if an item is generic or cross-crate inlinable, then it will have its
//! code generated by some downstream crate. Now if that item calls private monomorphic
//! non-cross-crate-inlinable items, then those can be reached by the code generated by the
//! downstream create! Therefore, when a reachable thing is cross-crate inlinable or generic, it
//! makes all other functions that it references reachable as well.
use hir::def_id::LocalDefIdSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
Expand Down Expand Up @@ -394,6 +400,7 @@ fn has_custom_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
}

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

Expand Down

0 comments on commit f93664e

Please sign in to comment.