about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-03-11 23:28:22 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-03-11 23:59:02 +0000
commite926f281dfc9baec0e01fb6aa82eb1bf8a0645c4 (patch)
treebca71d5a800088a75fad2d90a32ff0bfb9738b2c
parente742da0c71fc65facfa04df045839a230f059d42 (diff)
downloadrust-e926f281dfc9baec0e01fb6aa82eb1bf8a0645c4.tar.gz
rust-e926f281dfc9baec0e01fb6aa82eb1bf8a0645c4.zip
Comment `resolve_item_in_lexical_scope`
-rw-r--r--src/librustc_resolve/lib.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index eefef015636..468c560b0bd 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -1443,6 +1443,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                                            span)
     }
 
+    /// This function resolves `name` in `namespace` in the current lexical scope, returning
+    /// Success(binding) if `name` resolves to an item, or Failed(None) if `name` does not resolve
+    /// or resolves to a type parameter or local variable.
+    /// n.b. `resolve_identifier_in_local_ribs` also resolves names in the current lexical scope.
+    ///
     /// Invariant: This must only be called during main resolution, not during
     /// import resolution.
     fn resolve_item_in_lexical_scope(&mut self,
@@ -1450,9 +1455,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                                      namespace: Namespace,
                                      record_used: bool)
                                      -> ResolveResult<&'a NameBinding<'a>> {
-        // Check the local set of ribs.
+        // Walk backwards up the ribs in scope.
         for i in (0 .. self.get_ribs(namespace).len()).rev() {
             if let Some(_) = self.get_ribs(namespace)[i].bindings.get(&name).cloned() {
+                // The name resolves to a type parameter or local variable, so return Failed(None).
                 return Failed(None);
             }
 
@@ -1462,6 +1468,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                                                                       namespace,
                                                                       true,
                                                                       record_used) {
+                    // The name resolves to an item.
                     return Success(binding);
                 }
                 // We can only see through anonymous modules