]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/hir/map/mod.rs
Fix tests and assertions; add some comments
[rust.git] / src / librustc / hir / map / mod.rs
index f5f9bcd3b5ea5125d32e70cd09a2028e57dd2266..7a20146130d9480e640e0d1ba328bd980eed2b38 100644 (file)
@@ -204,7 +204,7 @@ pub fn read(&self, id: NodeId) {
         if let Some(entry) = self.map[id.as_usize()] {
             self.dep_graph.read_index(entry.dep_node);
         } else {
-            bug!("called `HirMap::read()` with invalid `NodeId`")
+            bug!("called `HirMap::read()` with invalid `NodeId`: {:?}", id)
         }
     }
 
@@ -344,6 +344,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
             Node::AnonConst(_) |
             Node::Expr(_) |
             Node::Stmt(_) |
+            Node::PathSegment(_) |
             Node::Ty(_) |
             Node::TraitRef(_) |
             Node::Pat(_) |
@@ -884,6 +885,7 @@ pub fn span(&self, id: NodeId) -> Span {
             Some(Node::AnonConst(constant)) => self.body(constant.body).value.span,
             Some(Node::Expr(expr)) => expr.span,
             Some(Node::Stmt(stmt)) => stmt.span,
+            Some(Node::PathSegment(seg)) => seg.ident.span,
             Some(Node::Ty(ty)) => ty.span,
             Some(Node::TraitRef(tr)) => tr.path.span,
             Some(Node::Binding(pat)) => pat.span,
@@ -1098,6 +1100,7 @@ pub fn print_node(&mut self, node: Node<'_>) -> io::Result<()> {
             Node::AnonConst(a)    => self.print_anon_const(&a),
             Node::Expr(a)         => self.print_expr(&a),
             Node::Stmt(a)         => self.print_stmt(&a),
+            Node::PathSegment(a)  => self.print_path_segment(&a),
             Node::Ty(a)           => self.print_type(&a),
             Node::TraitRef(a)     => self.print_trait_ref(&a),
             Node::Binding(a)      |
@@ -1215,6 +1218,9 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
         Some(Node::Stmt(_)) => {
             format!("stmt {}{}", map.node_to_pretty_string(id), id_str)
         }
+        Some(Node::PathSegment(_)) => {
+            format!("path segment {}{}", map.node_to_pretty_string(id), id_str)
+        }
         Some(Node::Ty(_)) => {
             format!("type {}{}", map.node_to_pretty_string(id), id_str)
         }