diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-03-21 06:56:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-21 06:56:47 +0100 |
| commit | 1135a632861710c6c42b25324e60319a2226d1ca (patch) | |
| tree | 108ab2e941d773c762c8771f6b785e94086fef90 | |
| parent | 7c1b128383a397945686dba983747bd1b0efd43e (diff) | |
| parent | b5069da9df85b8f374a3fd59c2145396e374537d (diff) | |
| download | rust-1135a632861710c6c42b25324e60319a2226d1ca.tar.gz rust-1135a632861710c6c42b25324e60319a2226d1ca.zip | |
Rollup merge of #138724 - fmease:list-stems-bear-no-name, r=nnethercote
Check attrs: Don't try to retrieve the name of list stems Fixes #138723. r? nnethercote or compiler
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 3 | ||||
| -rw-r--r-- | tests/ui/rustdoc/doc-alias-use-item-list-stem.rs | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index dca6f2959d2..e0739c342df 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -954,8 +954,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 00000000000..ef310843e21 --- /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: <https://github.com/rust-lang/rust/issues/138723> +//@ check-pass + +#[doc(alias = "empty")] +pub use {}; + +#[doc(alias = "id")] +pub use {std::convert::identity}; + +fn main() {} |
