From b5069da9df85b8f374a3fd59c2145396e374537d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 19 Mar 2025 22:44:19 +0100 Subject: [PATCH] Check attrs: Don't try to retrieve the name of list stems --- compiler/rustc_passes/src/check_attr.rs | 3 +-- tests/ui/rustdoc/doc-alias-use-item-list-stem.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tests/ui/rustdoc/doc-alias-use-item-list-stem.rs diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d1917f39c07f7..bba172ce14421 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -952,8 +952,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { tcx.dcx().emit_err(errors::DocAliasBadLocation { span, attr_str, location }); return; } - let item_name = self.tcx.hir_name(hir_id); - if item_name == doc_alias { + if self.tcx.hir_opt_name(hir_id) == Some(doc_alias) { tcx.dcx().emit_err(errors::DocAliasNotAnAlias { span, attr_str }); return; } diff --git a/tests/ui/rustdoc/doc-alias-use-item-list-stem.rs b/tests/ui/rustdoc/doc-alias-use-item-list-stem.rs new file mode 100644 index 0000000000000..ef310843e2136 --- /dev/null +++ b/tests/ui/rustdoc/doc-alias-use-item-list-stem.rs @@ -0,0 +1,11 @@ +// Check that we don't ICE on `#[doc(alias)]`es placed on use items with list stems. +// issue: +//@ check-pass + +#[doc(alias = "empty")] +pub use {}; + +#[doc(alias = "id")] +pub use {std::convert::identity}; + +fn main() {}