Skip to content

Commit

Permalink
rustdoc: Add explanation when linting against public to private item …
Browse files Browse the repository at this point in the history
…links

The additional note helps explaining why the lint was triggered and that
--document-private-items directly influences the link resolution.
  • Loading branch information
dennis-hamester committed Jul 22, 2020
1 parent ed53de0 commit c14641a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Expand Up @@ -1076,6 +1076,13 @@ fn privacy_error(
if let Some(sp) = sp {
diag.span_label(sp, "this item is private");
}

let note_msg = if cx.render_options.document_private {
"this link resolves only because you passed `--document-private-items`, but will break without"
} else {
"this link will resolve properly if you pass `--document-private-items`"
};
diag.note(note_msg);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc-ui/intra-links-private.private.stderr
Expand Up @@ -5,6 +5,7 @@ LL | /// docs [DontDocMe]
| ^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
= note: this link resolves only because you passed `--document-private-items`, but will break without

warning: 1 warning emitted

1 change: 1 addition & 0 deletions src/test/rustdoc-ui/intra-links-private.public.stderr
Expand Up @@ -5,6 +5,7 @@ LL | /// docs [DontDocMe]
| ^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
= note: this link will resolve properly if you pass `--document-private-items`

warning: 1 warning emitted

1 change: 1 addition & 0 deletions src/test/rustdoc-ui/issue-74134.private.stderr
Expand Up @@ -5,6 +5,7 @@ LL | /// [`PrivateType`]
| ^^^^^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
= note: this link resolves only because you passed `--document-private-items`, but will break without

warning: 1 warning emitted

1 change: 1 addition & 0 deletions src/test/rustdoc-ui/issue-74134.public.stderr
Expand Up @@ -5,6 +5,7 @@ LL | /// [`PrivateType`]
| ^^^^^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
= note: this link will resolve properly if you pass `--document-private-items`

warning: 1 warning emitted

0 comments on commit c14641a

Please sign in to comment.