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
--- /dev/null
+// Regression test for the ICE described in #83512.
+
+#![feature(doc_keyword)]
+#![crate_type="lib"]
+
+trait Foo {
+ #[doc(keyword = "match")]
+ //~^ ERROR: `#[doc(keyword = "...")]` can only be used on modules
+ fn quux() {}
+}
--- /dev/null
+error: `#[doc(keyword = "...")]` can only be used on modules
+ --> $DIR/issue-83512.rs:7:11
+ |
+LL | #[doc(keyword = "match")]
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+