From 06931988c009b7467b6545cad2d6fb3597a29adf Mon Sep 17 00:00:00 2001 From: Camelid Date: Sun, 27 Dec 2020 16:53:57 -0800 Subject: [PATCH] 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 --- compiler/rustc_resolve/src/lib.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 0de732b2cf9..ad584a69697 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -456,28 +456,36 @@ struct BindingKey { type Resolutions<'a> = RefCell>>>; /// One node in the tree of modules. +/// +/// Note that "module" is a loose term here; it does not necessarily mean +/// a `mod` that you declare in Rust code. It may also be, e.g., a trait +/// or an enum. See [`ModuleKind`] (accessible through [`ModuleData::kind`] +/// for all of the kinds of "modules" that resolve deals with. pub struct ModuleData<'a> { + /// The direct parent module (it may not be a `mod`, however). parent: Option>, + /// What kind of module this is, because this may not be a `mod`. kind: ModuleKind, - // The def id of the closest normal module (`mod`) ancestor (including this module). + /// The [`DefId`] of the closest `mod` item ancestor (which may be this module), including crate root. normal_ancestor_id: DefId, - // Mapping between names and their (possibly in-progress) resolutions in this module. - // Resolutions in modules from other crates are not populated until accessed. + /// Mapping between names and their (possibly in-progress) resolutions in this module. + /// Resolutions in modules from other crates are not populated until accessed. lazy_resolutions: Resolutions<'a>, - // True if this is a module from other crate that needs to be populated on access. + /// True if this is a module from other crate that needs to be populated on access. populate_on_access: Cell, - // Macro invocations that can expand into items in this module. + /// Macro invocations that can expand into items in this module. unexpanded_invocations: RefCell>, + /// Whether `#[no_implicit_prelude]` is active. no_implicit_prelude: bool, glob_importers: RefCell>>, globs: RefCell>>, - // Used to memoize the traits in this module for faster searches through all traits in scope. + /// Used to memoize the traits in this module for faster searches through all traits in scope. traits: RefCell)]>>>, /// Span of the module itself. Used for error reporting.