Skip to content

Commit 0693198

Browse files
committed
Document ModuleData
* Convert comments on fields to doc comments so they're visible in API docs * Add new documentation * Get rid of "normal module" terminology
1 parent 8fec6c7 commit 0693198

File tree

1 file changed

+14
-6
lines changed
  • compiler/rustc_resolve/src

1 file changed

+14
-6
lines changed

compiler/rustc_resolve/src/lib.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -456,28 +456,36 @@ struct BindingKey {
456456
type Resolutions<'a> = RefCell<FxIndexMap<BindingKey, &'a RefCell<NameResolution<'a>>>>;
457457

458458
/// One node in the tree of modules.
459+
///
460+
/// Note that "module" is a loose term here; it does not necessarily mean
461+
/// a `mod` that you declare in Rust code. It may also be, e.g., a trait
462+
/// or an enum. See [`ModuleKind`] (accessible through [`ModuleData::kind`]
463+
/// for all of the kinds of "modules" that resolve deals with.
459464
pub struct ModuleData<'a> {
465+
/// The direct parent module (it may not be a `mod`, however).
460466
parent: Option<Module<'a>>,
467+
/// What kind of module this is, because this may not be a `mod`.
461468
kind: ModuleKind,
462469

463-
// The def id of the closest normal module (`mod`) ancestor (including this module).
470+
/// The [`DefId`] of the closest `mod` item ancestor (which may be this module), including crate root.
464471
normal_ancestor_id: DefId,
465472

466-
// Mapping between names and their (possibly in-progress) resolutions in this module.
467-
// Resolutions in modules from other crates are not populated until accessed.
473+
/// Mapping between names and their (possibly in-progress) resolutions in this module.
474+
/// Resolutions in modules from other crates are not populated until accessed.
468475
lazy_resolutions: Resolutions<'a>,
469-
// True if this is a module from other crate that needs to be populated on access.
476+
/// True if this is a module from other crate that needs to be populated on access.
470477
populate_on_access: Cell<bool>,
471478

472-
// Macro invocations that can expand into items in this module.
479+
/// Macro invocations that can expand into items in this module.
473480
unexpanded_invocations: RefCell<FxHashSet<ExpnId>>,
474481

482+
/// Whether `#[no_implicit_prelude]` is active.
475483
no_implicit_prelude: bool,
476484

477485
glob_importers: RefCell<Vec<&'a Import<'a>>>,
478486
globs: RefCell<Vec<&'a Import<'a>>>,
479487

480-
// Used to memoize the traits in this module for faster searches through all traits in scope.
488+
/// Used to memoize the traits in this module for faster searches through all traits in scope.
481489
traits: RefCell<Option<Box<[(Ident, &'a NameBinding<'a>)]>>>,
482490

483491
/// Span of the module itself. Used for error reporting.

0 commit comments

Comments
 (0)