]> git.lizzy.rs Git - rust.git/commitdiff
improve hir::map::Map::get_parent_node doc
authorRalf Jung <post@ralfj.de>
Wed, 2 Aug 2017 02:13:47 +0000 (19:13 -0700)
committerRalf Jung <post@ralfj.de>
Wed, 2 Aug 2017 02:22:23 +0000 (19:22 -0700)
src/librustc/hir/map/mod.rs

index 3fdd9c34f46d9f130a94bb7f695cfeb403a6d0d3..45b1d6c184101bc2511be389378070dacd0cf715 100644 (file)
@@ -553,7 +553,9 @@ pub fn find(&self, id: NodeId) -> Option<Node<'hir>> {
     }
 
     /// Similar to get_parent, returns the parent node id or id if there is no
-    /// parent.
+    /// parent. Note that the parent may be CRATE_NODE_ID, which is not itself
+    /// present in the map -- so passing the return value of get_parent_node to
+    /// get may actually panic.
     /// This function returns the immediate parent in the AST, whereas get_parent
     /// returns the enclosing item. Note that this might not be the actual parent
     /// node in the AST - some kinds of nodes are not in the map and these will
@@ -629,7 +631,7 @@ fn walk_parent_nodes<F, F2>(&self,
     }
 
     /// Retrieve the NodeId for `id`'s enclosing method, unless there's a
-    /// `while` or `loop` before reacing it, as block tail returns are not
+    /// `while` or `loop` before reaching it, as block tail returns are not
     /// available in them.
     ///
     /// ```