about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/hir/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/hir/map.rs')
-rw-r--r--compiler/rustc_middle/src/hir/map.rs36
1 files changed, 19 insertions, 17 deletions
diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs
index c61c7a4fb02..2e589150d3e 100644
--- a/compiler/rustc_middle/src/hir/map.rs
+++ b/compiler/rustc_middle/src/hir/map.rs
@@ -385,7 +385,7 @@ impl<'tcx> TyCtxt<'tcx> {
     pub fn hir_get_module(self, module: LocalModDefId) -> (&'tcx Mod<'tcx>, Span, HirId) {
         let hir_id = HirId::make_owner(module.to_local_def_id());
         match self.hir_owner_node(hir_id.owner) {
-            OwnerNode::Item(&Item { span, kind: ItemKind::Mod(m), .. }) => (m, span, hir_id),
+            OwnerNode::Item(&Item { span, kind: ItemKind::Mod(_, m), .. }) => (m, span, hir_id),
             OwnerNode::Crate(item) => (item, item.spans.inner_span, hir_id),
             node => panic!("not a module: {node:?}"),
         }
@@ -847,7 +847,7 @@ impl<'tcx> TyCtxt<'tcx> {
             // A `Ctor` doesn't have an identifier itself, but its parent
             // struct/variant does. Compare with `hir::Map::span`.
             Node::Ctor(..) => match self.parent_hir_node(id) {
-                Node::Item(item) => Some(item.ident),
+                Node::Item(item) => Some(item.kind.ident().unwrap()),
                 Node::Variant(variant) => Some(variant.ident),
                 _ => unreachable!(),
             },
@@ -894,18 +894,14 @@ impl<'hir> Map<'hir> {
         }
 
         fn named_span(item_span: Span, ident: Ident, generics: Option<&Generics<'_>>) -> Span {
-            if ident.name != kw::Empty {
-                let mut span = until_within(item_span, ident.span);
-                if let Some(g) = generics
-                    && !g.span.is_dummy()
-                    && let Some(g_span) = g.span.find_ancestor_inside(item_span)
-                {
-                    span = span.to(g_span);
-                }
-                span
-            } else {
-                item_span
+            let mut span = until_within(item_span, ident.span);
+            if let Some(g) = generics
+                && !g.span.is_dummy()
+                && let Some(g_span) = g.span.find_ancestor_inside(item_span)
+            {
+                span = span.to(g_span);
             }
+            span
         }
 
         let span = match self.tcx.hir_node(hir_id) {
@@ -936,7 +932,7 @@ impl<'hir> Map<'hir> {
             }) => until_within(*outer_span, generics.where_clause_span),
             // Constants and Statics.
             Node::Item(Item {
-                kind: ItemKind::Const(ty, ..) | ItemKind::Static(ty, ..),
+                kind: ItemKind::Const(_, ty, ..) | ItemKind::Static(_, ty, ..),
                 span: outer_span,
                 ..
             })
@@ -957,7 +953,7 @@ impl<'hir> Map<'hir> {
             }) => until_within(*outer_span, ty.span),
             // With generics and bounds.
             Node::Item(Item {
-                kind: ItemKind::Trait(_, _, generics, bounds, _),
+                kind: ItemKind::Trait(_, _, _, generics, bounds, _),
                 span: outer_span,
                 ..
             })
@@ -977,7 +973,13 @@ impl<'hir> Map<'hir> {
                     // SyntaxContext of the path.
                     path.span.find_ancestor_in_same_ctxt(item.span).unwrap_or(item.span)
                 }
-                _ => named_span(item.span, item.ident, item.kind.generics()),
+                _ => {
+                    if let Some(ident) = item.kind.ident() {
+                        named_span(item.span, ident, item.kind.generics())
+                    } else {
+                        item.span
+                    }
+                }
             },
             Node::Variant(variant) => named_span(variant.span, variant.ident, None),
             Node::ImplItem(item) => named_span(item.span, item.ident, Some(item.generics)),
@@ -1327,7 +1329,7 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
         self.items.push(item.item_id());
 
         // Items that are modules are handled here instead of in visit_mod.
-        if let ItemKind::Mod(module) = &item.kind {
+        if let ItemKind::Mod(_, module) = &item.kind {
             self.submodules.push(item.owner_id);
             // A module collector does not recurse inside nested modules.
             if self.crate_collector {