Skip to content

Module items not in scoped for module //! comment when module also has /// comment #134904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
xmppftw opened this issue Dec 29, 2024 · 2 comments
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@xmppftw
Copy link

xmppftw commented Dec 29, 2024

Not very clear how //! in top of module or /// before 'mod' declaration works and what difference. I found one big difference when doing /// then in rest of //! at top of module, module items are not in the scoped.

I understand it's normal module importer doesnt ahve module items in scoped by default. But its not normal that module itself doesnt have items in the scoped.

Smallest reproduction case: https://github.com/xmppftw/rustrepro/tree/issue-134904

  • maybe it's a bug?
  • maybe it's bad to use /// and //! but i dont see this in rustdoc book or somewhere else
@xmppftw xmppftw added the C-bug Category: This is a bug. label Dec 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 29, 2024
@jieyouxu jieyouxu added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Dec 29, 2024
@aDotInTheVoid aDotInTheVoid changed the title Module items not in scoped for module comment //! when module has /// comment Module items not in scoped for module //! comment when module also has /// comment Jan 9, 2025
@aDotInTheVoid
Copy link
Member

Minimal:

/// Outer doc-comment.
pub mod demo {
    //!
    //! Inner doc-comment with link: [`DemoStruct`]

    pub struct DemoStruct;
}

Which produces the following warning:

warning: unresolved link to `DemoStruct`
 --> ./src/lib.rs:4:40
  |
4 |     //! Inner doc-comment with link: [`DemoStruct`]
  |                                        ^^^^^^^^^^ no item named `DemoStruct` in scope
  |
  = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
  = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default

warning: 1 warning emitted

and doesn't resolve the link:

Image


Whereas if you remove the outer doc-comment, it works as expected:

Image


I think this is happening because we merge the outer and inner doc-comment before resolving intra-doc-links (but I've not checked).

@aDotInTheVoid aDotInTheVoid added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 9, 2025
@lolbinarycat
Copy link
Contributor

possible duplicate of #119965?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants