about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-02-03 15:59:35 -0500
committerNiko Matsakis <niko@alum.mit.edu>2016-02-18 05:26:30 -0500
commitdaa74082670af4622044f6b1bae1e3e49fa1ef38 (patch)
tree07a7856e8ed95a90488fc8455809cd92d3b0d1ad
parenta80d449026dc22a55ff544862f2f54846cee0813 (diff)
Fix a weird case in the HIR map, where fields are not present in the
map. Perhaps I ought to just add them instead, but this seems harmless
enough.
-rw-r--r--src/librustc/front/map/mod.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/librustc/front/map/mod.rs b/src/librustc/front/map/mod.rs
index 53a311f95da..adf14d0d89c 100644
--- a/src/librustc/front/map/mod.rs
+++ b/src/librustc/front/map/mod.rs
@@ -325,7 +325,17 @@ impl<'ast> Map<'ast> {
                     return DepNode::Krate,
 
                 NotPresent =>
-                    panic!("Walking parents from `{}` led to `NotPresent` at `{}`", id0, id),
+                    // Some nodes, notably struct fields, are not
+                    // present in the map for whatever reason, but
+                    // they *do* have def-ids. So if we encounter an
+                    // empty hole, check for that case.
+                    return self.opt_local_def_id(id)
+                               .map(|def_id| DepNode::Hir(def_id))
+                               .unwrap_or_else(|| {
+                                   panic!("Walking parents from `{}` \
+                                           led to `NotPresent` at `{}`",
+                                          id0, id)
+                               }),
             }
         }
     }