Skip to content

Commit daa7408

Browse files
committed
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.
1 parent a80d449 commit daa7408

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/librustc/front/map/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,17 @@ impl<'ast> Map<'ast> {
325325
return DepNode::Krate,
326326

327327
NotPresent =>
328-
panic!("Walking parents from `{}` led to `NotPresent` at `{}`", id0, id),
328+
// Some nodes, notably struct fields, are not
329+
// present in the map for whatever reason, but
330+
// they *do* have def-ids. So if we encounter an
331+
// empty hole, check for that case.
332+
return self.opt_local_def_id(id)
333+
.map(|def_id| DepNode::Hir(def_id))
334+
.unwrap_or_else(|| {
335+
panic!("Walking parents from `{}` \
336+
led to `NotPresent` at `{}`",
337+
id0, id)
338+
}),
329339
}
330340
}
331341
}

0 commit comments

Comments
 (0)