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

rustdoc: use stability, instead of features, to decide what to show #124864

Conversation

notriddle
Copy link
Contributor

Fixes #124635

To decide if internal items should be inlined in a doc page, check if the crate is itself internal, rather than if it has the rustc_private feature flag. The standard library uses internal items, but is not itself internal and should not show internal items on its docs pages.

@rustbot
Copy link
Collaborator

rustbot commented May 7, 2024

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 7, 2024
@notriddle notriddle force-pushed the notriddle/feature-flags-are-not-stability-markers branch from a7efed9 to ffee30a Compare May 7, 2024 22:34
@workingjubilee
Copy link
Member

Thanks for taking care of this!

src/librustdoc/clean/inline.rs Outdated Show resolved Hide resolved
src/librustdoc/clean/inline.rs Outdated Show resolved Hide resolved
return;
}

if !tcx.features().rustc_private && !cx.render_options.force_unstable_if_unmarked {
Copy link
Member

Choose a reason for hiding this comment

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

quick question, why wouldn't the following be a potential solution:

if !cx.render_options.force_unstable_if_unmarked {

(just removing the F-rustc_private check)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be a potential solution, but it requires more code than is_compiler_internal(LOCAL_CRATE.as_def_id()). I'm trying to simplify this code, because I had trouble understanding the old version.

#![crate_name = "foo"]
#![feature(rustc_private)]

extern crate issue_76736_1;
extern crate issue_76736_2;

// @has foo/struct.Foo.html
// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
// @!has - '//*[@class="impl"]//h3[@class="code-header"]' 'MaybeResult'
Copy link
Member

@fmease fmease May 7, 2024

Choose a reason for hiding this comment

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

I don't know, couldn't this impl be useful? The user is explicitly opting into using internal APIs with #![feature(rustc_private)], then why should we refuse them access to potential useful information (here: “impl MaybeResult for Foo” via the upstream blanket impl, which they can indeed make use of)

I feel like I'm missing something obvious. If I'm not mistaken the suggestion from my review comment one above wouldn't throw this impl out and would still fix the linked issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

“The user,” in this case, is the standard library. It uses the feature rudtc_private, but doesn’t want private items to show up in its docs.

Copy link
Member

@fmease fmease May 8, 2024

Choose a reason for hiding this comment

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

Well, the std library doesn't contain #[feature(rustc_internal)] directly as you probably know but yeah.

There are other users of rustc_internal. I' on mobile rn but yesterday I grepped through compiler/ and saw the feature being enabled for one of the alternate backends (cranelift or gcc, I don't remember) and I assume rustfmt enables it too for rustc_{parse,ast}?

I'm just nitpicking but I don't wanna block this PR any longer.

To decide if internal items should be inlined in a doc page,
check if the crate is itself internal, rather than if it has
the rustc_private feature flag. The standard library uses
internal items, but is not itself internal and should not show
internal items on its docs pages.
@notriddle notriddle force-pushed the notriddle/feature-flags-are-not-stability-markers branch from ffee30a to 6d6f67a Compare May 8, 2024 03:47
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

The approach looks fine, although I still have some doubts as elaborated in my other comments.

I wonder if the tests should use //@ compile-flags: -Zforce-unstable-if-unmarked instead of #![feature(rustc_internals)] to be “closer to reality” but eh, not pressing.

@fmease
Copy link
Member

fmease commented May 8, 2024

Does this need backporting?

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 8, 2024

📌 Commit 6d6f67a has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2024
…iaskrgr

Rollup of 3 pull requests

Successful merges:

 - rust-lang#124548 (Handle normalization failure in `struct_tail_erasing_lifetimes`)
 - rust-lang#124761 (Fix insufficient logic when searching for the underlying allocation)
 - rust-lang#124864 (rustdoc: use stability, instead of features, to decide what to show)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5347652 into rust-lang:master May 8, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 8, 2024
Rollup merge of rust-lang#124864 - notriddle:notriddle/feature-flags-are-not-stability-markers, r=fmease

rustdoc: use stability, instead of features, to decide what to show

Fixes rust-lang#124635

To decide if internal items should be inlined in a doc page, check if the crate is itself internal, rather than if it has the rustc_private feature flag. The standard library uses internal items, but is not itself internal and should not show internal items on its docs pages.
@rustbot rustbot added this to the 1.80.0 milestone May 8, 2024
@notriddle notriddle deleted the notriddle/feature-flags-are-not-stability-markers branch May 8, 2024 19:40
@notriddle notriddle added the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 8, 2024
@fmease
Copy link
Member

fmease commented May 10, 2024

Backport to beta approved as per Zulip poll.

@rustbot label beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label May 10, 2024
@cuviper cuviper mentioned this pull request May 16, 2024
@cuviper cuviper modified the milestones: 1.80.0, 1.79.0 May 16, 2024
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label May 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 17, 2024
[beta] backports

- Do not ICE on foreign malformed `diagnostic::on_unimplemented` rust-lang#124683
- Fix more ICEs in `diagnostic::on_unimplemented` rust-lang#124875
- rustdoc: use stability, instead of features, to decide what to show rust-lang#124864
- Don't do post-method-probe error reporting steps if we're in a suggestion rust-lang#125100
-  Make `non-local-def` lint Allow by default rust-lang#124950

r? cuviper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doc for std contains broken links in the implementors sections
7 participants