Skip to content

Commit 433a03e

Browse files
committed
fixup! Some comments and documentation for name resolution crate
1 parent 68d6edd commit 433a03e

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/librustc_resolve/lib.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,9 @@ enum RibKind<'a> {
878878
///
879879
/// A rib represents a scope names can live in. Note that these appear in many places, not just
880880
/// around braces. At any place where the list of accessible names (of the given namespace)
881-
/// changes, a new rib is put onto a stack. This may be, for example, a `let` statement (because it
882-
/// introduces variables), a macro, etc.
881+
/// changes or a new restrictions on the name accessibility are introduced, a new rib is put onto a
882+
/// stack. This may be, for example, a `let` statement (because it introduces variables), a macro,
883+
/// etc.
883884
///
884885
/// Different [rib kinds](enum.RibKind) are transparent for different names.
885886
///
@@ -935,11 +936,26 @@ enum PathResult<'a> {
935936
}
936937

937938
enum ModuleKind {
938-
/// Inline `mod something { ... }`.
939+
/// An anonymous module, eg. just a block.
940+
///
941+
/// ```
942+
/// fn main() {
943+
/// fn f() {} // (1)
944+
/// { // This is an anonymous module
945+
/// f(); // This resolves to (2) as we are inside the block.
946+
/// fn f() {} // (2)
947+
/// }
948+
/// f(); // Resolves to (1)
949+
/// }
950+
/// ```
939951
Block(NodeId),
940-
/// Module from another file.
952+
/// Any module with a name.
953+
///
954+
/// This could be:
941955
///
942-
/// Also called a normal module in the following code.
956+
/// * A normal module ‒ either `mod from_file;` or `mod from_block { }`.
957+
/// * A trait or an enum (it implicitly contains associated types, methods and variant
958+
/// constructors).
943959
Def(Def, Name),
944960
}
945961

@@ -1444,8 +1460,8 @@ impl<'a, 'b: 'a> ty::DefIdTree for &'a Resolver<'b> {
14441460
}
14451461
}
14461462

1447-
/// This is the interface through which the rest of the compiler asks about name resolution after
1448-
/// the whole AST has been indexed.
1463+
/// This interface is used through the AST→HIR step, to embed full paths into the HIR. After that
1464+
/// the resolver is no longer needed as all the relevant information is inline.
14491465
impl<'a> hir::lowering::Resolver for Resolver<'a> {
14501466
fn resolve_hir_path(&mut self, path: &mut hir::Path, is_value: bool) {
14511467
self.resolve_hir_path_cb(path, is_value,

0 commit comments

Comments
 (0)