Open
Description
⚠️ Warning ⚠️
Discussion needs to take place and agreement needs to be reached before implementing this! See #83049 (comment).
This should succeed, but it does not.
mod foo {
//! Look at [super::bar::baz].
}
mod bar {
fn baz() {}
}
$ rustdoc foo.rs --document-private-items
warning: unresolved link to `super::bar::baz`
--> foo.rs:2:18
|
2 | //! Look at [super::bar::baz].
| ^^^^^^^^^^^^^^^ no item named `baz` in module `bar`
|
= note: `#[warn(broken_intra_doc_links)]` on by default
warning: 1 warning emitted
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jyn514 commentedon Mar 12, 2021
Does it work without
super
? Inner attributes resolve relative to the module they're in.camelid commentedon Mar 13, 2021
Well, if you look at the label in the error message, the issue is not in finding
bar
, rather it's in findingbaz
withinbar
.Also, using
crate
doesn't fix it:Weirdly, it says
self::bar::baz
—it should saycrate::bar::baz
. Probably an unrelated bug.jyn514 commentedon Mar 14, 2021
rust/src/librustdoc/passes/collect_intra_doc_links.rs
Lines 1038 to 1054 in acca818
jyn514 commentedon Mar 14, 2021
I think the error is actually correct -
baz
is not visible tofoo
because it's in a different module. The diagnostic could be better though.camelid commentedon Mar 14, 2021
I thought you're allowed to link to any private item from anywhere else...? I minimized this code from a project I'm working on, so there are definitely use cases.
jyn514 commentedon Mar 14, 2021
I don't think there's ever been docs on what private items you can link to. Notice that this is the "broken" lint and not the "private" lint - rustc_resolve itself is giving this error, not rustdoc, and it would need massive changes to be different (which I doubt @petrochenkov would be happy about).
camelid commentedon Apr 25, 2021
It looks like
rustc_resolve
is able to give a better error:I'm not 100% certain, but I think that error might be coming from here:
rust/compiler/rustc_resolve/src/lib.rs
Line 2923 in 42816d6
rust/compiler/rustc_resolve/src/diagnostics.rs
Lines 1129 to 1133 in 42816d6
rust/compiler/rustc_resolve/src/imports.rs
Lines 324 to 330 in 42816d6
Is there some way we can pick up on the fact that the item exists, but is private? Otherwise it's really confusing because the item does exist — so I end up trying to look for typos in the path, when in reality it's just that the item is private.
jyn514 commentedon Apr 25, 2021
@camelid that's #74207
12 remaining items