about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-06-17 16:45:26 +0200
committerFabian Wolff <fabian.wolff@alumni.ethz.ch>2021-06-17 16:45:26 +0200
commit2cedd86b1c25db321e7e023f6a429e23425a7e00 (patch)
tree4b1ce63f4306558f9cdfcb9c7e1489f34828eb8b /compiler
parentb17d9c1332693fc386f5374f0d63aae0ce5abab5 (diff)
downloadrust-2cedd86b1c25db321e7e023f6a429e23425a7e00.tar.gz
rust-2cedd86b1c25db321e7e023f6a429e23425a7e00.zip
Fix ICE when using `#[doc(keyword = "...")]` on non-items
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_passes/src/check_attr.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index eca84c791fb..e85392cf0bd 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -525,8 +525,11 @@ impl CheckAttrVisitor<'tcx> {
             self.doc_attr_str_error(meta, "keyword");
             return false;
         }
-        match self.tcx.hir().expect_item(hir_id).kind {
-            ItemKind::Mod(ref module) => {
+        match self.tcx.hir().find(hir_id).and_then(|node| match node {
+            hir::Node::Item(item) => Some(&item.kind),
+            _ => None,
+        }) {
+            Some(ItemKind::Mod(ref module)) => {
                 if !module.item_ids.is_empty() {
                     self.tcx
                         .sess