Skip to content
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

Document compiler/ with -Aprivate-intra-doc-links #83885

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions compiler/rustc_errors/src/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ macro_rules! forward {
pub fn $n:ident(&self, $($name:ident: $ty:ty),* $(,)?) -> &Self
) => {
$(#[$attrs])*
// we always document with --document-private-items
#[cfg_attr(not(bootstrap), allow(rustdoc::private_intra_doc_links))]
#[cfg_attr(bootstrap, allow(private_intra_doc_links))]
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
pub fn $n(&self, $($name: $ty),*) -> &Self {
self.diagnostic.$n($($name),*);
Expand All @@ -62,9 +59,6 @@ macro_rules! forward {
) => {
$(#[$attrs])*
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
// we always document with --document-private-items
#[cfg_attr(not(bootstrap), allow(rustdoc::private_intra_doc_links))]
#[cfg_attr(bootstrap, allow(private_intra_doc_links))]
pub fn $n(&mut self, $($name: $ty),*) -> &mut Self {
self.0.diagnostic.$n($($name),*);
self
Expand All @@ -82,9 +76,6 @@ macro_rules! forward {
) => {
$(#[$attrs])*
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
// we always document with --document-private-items
#[cfg_attr(not(bootstrap), allow(rustdoc::private_intra_doc_links))]
#[cfg_attr(bootstrap, allow(private_intra_doc_links))]
pub fn $n<$($generic: $bound),*>(&mut self, $($name: $ty),*) -> &mut Self {
self.0.diagnostic.$n($($name),*);
self
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ impl Step for Rustc {
// Build cargo command.
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "doc");
cargo.rustdocflag("--document-private-items");
// Since we always pass --document-private-items, there's no need to warn about linking to private items.
cargo.rustdocflag("-Arustdoc::private-intra-doc-links");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, should this perhaps go in builder::cargo along with the other lint configs, gated on Mode::Rustc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should go next to --document-private-items, wherever that is, so people can see they're related. Happy to move --document-private-items to builder::cargo if you think it's useful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason rustdoc isn't changing the default lint level when that flag is passed?

Copy link
Member Author

@jyn514 jyn514 Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually part of the error message:

error: public documentation for `ModuleData` links to private item `ModuleData::kind`
    |
    |
496 | /// You can use [`ModuleData::kind`] to determine the kind of module this is.
    |
    |
    = note: `-D rustdoc::private-intra-doc-links` implied by `-D warnings`
    = note: this link resolves only because you passed `--document-private-items`, but will break without

I do think it should be something intentional, I expect at least some people only document locally with --document-private-items and I think they should still see the warning unless they opt out. Otherwise the links will be broken on docs.rs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I'm not sure I buy that argument; users likely run in CI without document-private-items and so will see the error there (as warnings are likely to be denied). But regardless, that seems like an orthogonal discussion. I'm happy to merge this.

cargo.rustdocflag("--enable-index-page");
cargo.rustdocflag("-Zunstable-options");
cargo.rustdocflag("-Znormalize-docs");
Expand Down