rustdoc warns "no item in scope" due to extra doc string #119965
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.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
This is a minimal example of the problem; in my actual case
foo
is a separate file, which made the error harder to spot:Running
cargo doc
orrustdoc src/lib.rs
gives:Honestly I don't know what I expected to happen; in hindsight the doc comments don't make that much sense. But I think the error can be improved. This happened as I was starting to write docs for
foo
in my actualfoo.rs
and it took me a good while to first find the offending doc line and even consider that to be the problem.What seems to happen is that the presence of
/// foo is a module
makes rustdoc resolve links in the docs insidepub mod foo { }
as if they were written outside. In the generated docs the headers "My cool crate" and "Foo docs" appear concatenated into one. Removing/// foo is a module
makes the error go away and the link in the generated docs works as expected.I tried fixing it myself, but realized that it would take me a very long time, and besides I don't really know what an acceptable solution would be. My best suggestion is to make this an error and only allow either
/// blah mod foo;
ormod foo { //! blah }
Meta
This happens in both latest stable and nightly as well as in my own locally compiled
rustdoc
.There is no backtrace as rustdoc doesn't crash or error out but rather just prints a warning. Obviously this isn't an actual ICE. Changing the
format!
ting of the "no item named ..." error message into apanic!
gives this backtrace:backtrace
The text was updated successfully, but these errors were encountered: