Skip to content

Commit e926f28

Browse files
committed
Comment resolve_item_in_lexical_scope
1 parent e742da0 commit e926f28

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustc_resolve/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1443,16 +1443,22 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14431443
span)
14441444
}
14451445

1446+
/// This function resolves `name` in `namespace` in the current lexical scope, returning
1447+
/// Success(binding) if `name` resolves to an item, or Failed(None) if `name` does not resolve
1448+
/// or resolves to a type parameter or local variable.
1449+
/// n.b. `resolve_identifier_in_local_ribs` also resolves names in the current lexical scope.
1450+
///
14461451
/// Invariant: This must only be called during main resolution, not during
14471452
/// import resolution.
14481453
fn resolve_item_in_lexical_scope(&mut self,
14491454
name: Name,
14501455
namespace: Namespace,
14511456
record_used: bool)
14521457
-> ResolveResult<&'a NameBinding<'a>> {
1453-
// Check the local set of ribs.
1458+
// Walk backwards up the ribs in scope.
14541459
for i in (0 .. self.get_ribs(namespace).len()).rev() {
14551460
if let Some(_) = self.get_ribs(namespace)[i].bindings.get(&name).cloned() {
1461+
// The name resolves to a type parameter or local variable, so return Failed(None).
14561462
return Failed(None);
14571463
}
14581464

@@ -1462,6 +1468,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14621468
namespace,
14631469
true,
14641470
record_used) {
1471+
// The name resolves to an item.
14651472
return Success(binding);
14661473
}
14671474
// We can only see through anonymous modules

0 commit comments

Comments
 (0)