Skip to content

rustdoc: accept attribute@ disambiguator for attribute macros - #160903

Closed
sankalpsthakur wants to merge 1 commit into
rust-lang:mainfrom
sankalpsthakur:fix-159771-attribute-disambiguator
Closed

rustdoc: accept attribute@ disambiguator for attribute macros#160903
sankalpsthakur wants to merge 1 commit into
rust-lang:mainfrom
sankalpsthakur:fix-159771-attribute-disambiguator

Conversation

@sankalpsthakur

@sankalpsthakur sankalpsthakur commented Aug 11, 2026

Copy link
Copy Markdown

Summary

Rustdoc already suggested attribute@ when an intra-doc link resolved to an attribute macro with the wrong kind (for example example!), but Disambiguator::from_str did not recognize attribute, so applying the suggestion produced unknown disambiguator \attribute``.

This change:

Validation

  • Local full bootstrap was not run here (sparse/partial checkout; ~31 GiB free disk; no stage1 rustdoc build available).
  • Change is intentionally small (parser + docs + ui test). Please rely on CI ./x.py test tests/rustdoc-ui --stage 1 (or the relevant rustdoc jobs).

Fixes #159771

AI/LLM disclosure

  • AI coding tools (including Grok and/or Codex agent-assisted editing) were used to help draft or modify code and this PR description.
  • I reviewed the complete change, understand the reasoning, and prepared the reported local validation notes before submitting.
  • This submission is original work of authorship under the project CLA / contributor terms; AI output was not pasted unreviewed.

Rustdoc already suggested `attribute@` for attribute macros, but parsing
rejected it as unknown. Accept the prefix (symmetric with `derive@`) and
document it so the suggestion produces valid links.

Fixes rust-lang#159771

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 11, 2026
@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @notriddle (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 8 candidates
  • Random selection from GuillaumeGomez, lolbinarycat, notriddle

@rustbot

rustbot commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@oli-obk

oli-obk commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Hi,

For the last few months we have been receiving an increased amount of LLM generated contributions. We have no way to distinguish your PR from other generated ones and thus unfortunately need to put some additional barriers for contributions in your way.

We are a community of contributors, not just a code repository. We focus on contributors who desire to stay around and put in the work to produce high quality contributions or learn to do so.

We are thus restricting you (unfortunately github only offers bans as a method for this) as per our policies (1) and contribution standards (2) to from creating PRs and comments.

To make sure you can learn how to contribute and get your ability to comment and create PRs reinstated, we invite you to join https://rust-lang.zulipchat.com/join/rlfvpemsaacs3pfi6kwqnqjb/ and start a thread asking for a mentor, who will then ask us to lift the restrictions.

Thanks for understanding

Oli in the name of the mod team

@oli-obk oli-obk closed this Aug 11, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 11, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
To only update this specific test, also pass `--test-args intra-doc/issue-159771-attribute-disambiguator.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "/checkout/tests/rustdoc-ui/intra-doc/issue-159771-attribute-disambiguator.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-ui/intra-doc/issue-159771-attribute-disambiguator" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Cdebuginfo=0" "--edition=2024"
stdout: none
--- stderr -------------------------------
error: incompatible link kind for `example`
##[error]  --> /checkout/tests/rustdoc-ui/intra-doc/issue-159771-attribute-disambiguator.rs:17:32
   |
LL | /// Wrong bang disambiguator: [example!]
   |                                ^^^^^^^^ this link resolved to an attribute macro, which is not a macro
   |
note: the lint level is defined here
  --> /checkout/tests/rustdoc-ui/intra-doc/issue-159771-attribute-disambiguator.rs:3:9
   |
LL | #![deny(rustdoc::broken_intra_doc_links)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to link to the attribute macro, prefix with `attribute@`
   |
LL - /// Wrong bang disambiguator: [example!]
LL + /// Wrong bang disambiguator: [attribute@example]
   |

error: aborting due to 1 previous error
------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid broken link lint suggestion when referencing disambiguous attribute macro

5 participants