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

[intra-doc links] Don't check feature gates of items re-exported across crates #82295

Merged
merged 1 commit into from
Feb 22, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Feb 19, 2021

It should be never break another crate to re-export a public item.

Note that this doesn't check the feature gate at
all for other crates:

  • Feature-gates aren't currently serialized, so the only way to check
    the gate is with ad-hoc attribute checking.
  • Checking the feature gate twice (once when documenting the original
    crate and one when documenting the current crate) seems not great.

This should still catch using the feature most of the time though, since
people tend to document their own crates.

Closes #82284.

r? @Manishearth

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name labels Feb 19, 2021
@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 19, 2021
@rust-log-analyzer

This comment has been minimized.

@jyn514 jyn514 changed the title [intra-doc links] Don't check feature gates of items re-exported across crates [intra-doc links] Check the feature gates of the original crate, not the current crate Feb 19, 2021
@jyn514 jyn514 force-pushed the feature-gate branch 2 times, most recently from b4326e5 to 58cc89e Compare February 19, 2021 15:54
@Mark-Simulacrum
Copy link
Member

I would expect us to check the features at definition time; if we're re-exporting from a crate then we can bypass the feature check IMO, rather than re-verifying.

@jyn514
Copy link
Member Author

jyn514 commented Feb 19, 2021

I would expect us to check the features at definition time; if we're re-exporting from a crate then we can bypass the feature check IMO, rather than re-verifying.

The problem is that this feature is checked in rustdoc, and rustdoc may not be run on the original crate. Consider a proc-macro that's re-exported into a facade crate, where only the facade is documented.

@jyn514
Copy link
Member Author

jyn514 commented Feb 19, 2021

Checking this in rustc instead of rustdoc would require moving intra-doc link parsing into rustc proper, which has other problems: #79542

@jyn514
Copy link
Member Author

jyn514 commented Feb 19, 2021

Consider a proc-macro that's re-exported into a facade crate, where only the facade is documented.

Well, this isn't a very good example because rustdoc has to document the proc-macro, it won't be excluded by --no-deps. A better example is someone writing documentation but never testing it locally; cargo publish doesn't run rustdoc. Then anyone can re-export their items to bypass the feature gate.

@Mark-Simulacrum
Copy link
Member

It seems like ultimately this doesn't help much then, because the feature gate can get omitted in the upstream crate (and not noticed as being actually required), and that causes downstream breakage during documentation building. Can we just leave the "loophole" open perhaps, and not check not-local definitions for using enabled features?

@jyn514
Copy link
Member Author

jyn514 commented Feb 19, 2021

It seems like ultimately this doesn't help much then, because the feature gate can get omitted in the upstream crate (and not noticed as being actually required), and that causes downstream breakage during documentation building.

The difference is that there's something the upstream crate can do to fix the breakage (enable the feature gate). Right now the upstream crate can't do anything and each individual crate re-exporting has to enable the feature gate themselves.

Concretely, this means since std has #![feature(intra_doc_pointers)], serde will stop breaking when you try to document it.

@rust-log-analyzer

This comment has been minimized.

…ss crates

It should be never break another crate to re-export a public item.

Note that this doesn't check the feature gate at
*all* for other crates:

- Feature-gates aren't currently serialized, so the only way to check
  the gate is with ad-hoc attribute checking.
- Checking the feature gate twice (once when documenting the original
  crate and one when documenting the current crate) seems not great.

This should still catch using the feature most of the time though, since
people tend to document their own crates.
@jyn514 jyn514 changed the title [intra-doc links] Check the feature gates of the original crate, not the current crate [intra-doc links] Don't check feature gates of items re-exported across crates Feb 19, 2021
@jyn514
Copy link
Member Author

jyn514 commented Feb 19, 2021

This now checks the feature-gates of the crate where the item was defined, instead of the crate where it was re-exported.

I reverted this, now it only checks items in the local crate.

@camelid
Copy link
Member

camelid commented Feb 19, 2021

I believe Manish is on break to work on Vaccinate CA, so you probably want to re-assign this PR.

@jyn514
Copy link
Member Author

jyn514 commented Feb 19, 2021

@camelid do you have time to review?

@camelid
Copy link
Member

camelid commented Feb 19, 2021

Probably not soon, and also this bug seems too tricky for me to feel comfortable reviewing a fix for.

@Manishearth
Copy link
Member

I'm not "on break" i'm just slower to do reviews, and prefer to not take on large tasks. This is probably okay

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 20, 2021

📌 Commit fdb32e9 has been approved by Manishearth

@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 Feb 20, 2021
@jyn514
Copy link
Member Author

jyn514 commented Feb 21, 2021

Seems spurious:

2021-02-21T03:46:15.1791994Z ##[section]Starting: Request a runner to run this job
2021-02-21T03:46:20.8597228Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'macos-latest'
2021-02-21T03:46:20.9129134Z Can't find any online and idle self-hosted runner in current repository's organization account that matches the required labels: 'macos-latest'
2021-02-21T03:46:21.0693717Z Found online and idle hosted runner in current repository's organization account that matches the required labels: 'macos-latest'
2021-02-21T03:46:21.1705953Z ##[section]Finishing: Request a runner to run this job

@bors retry

@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 Feb 21, 2021
@bors
Copy link
Contributor

bors commented Feb 21, 2021

⌛ Testing commit fdb32e9 with merge c9905c59729e4ca0b67db0917344fea83c368cff...

@bors
Copy link
Contributor

bors commented Feb 21, 2021

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 21, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@jyn514
Copy link
Member Author

jyn514 commented Feb 21, 2021

2021-02-21T19:34:55.6912480Z ##[section]Starting: Request a runner to run this job
2021-02-21T19:34:56.0401064Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'ubuntu-latest'
2021-02-21T19:34:56.0902101Z Can't find any online and idle self-hosted runner in current repository's organization account that matches the required labels: 'ubuntu-latest'
2021-02-21T19:34:56.2419675Z Found online and idle hosted runner in current repository's organization account that matches the required labels: 'ubuntu-latest'
2021-02-21T19:34:56.4622354Z ##[section]Finishing: Request a runner to run this job

😕 @rust-lang/infra do you know why this keeps failing? It's happened twice now.

@bors retry

@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 Feb 21, 2021
@bors
Copy link
Contributor

bors commented Feb 22, 2021

⌛ Testing commit fdb32e9 with merge 24bfcee...

@Dylan-DPC-zz
Copy link

@bors rollup=never

@bors
Copy link
Contributor

bors commented Feb 22, 2021

☀️ Test successful - checks-actions
Approved by: Manishearth
Pushing 24bfcee to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 22, 2021
@bors bors merged commit 24bfcee into rust-lang:master Feb 22, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 22, 2021
@jyn514 jyn514 deleted the feature-gate branch February 22, 2021 02:45
@jyn514
Copy link
Member Author

jyn514 commented Feb 22, 2021

Note: although this landed in 1.52 and #81015 landed in 1.51, it doesn't need to be backported because the first time this syntax of link was in libstd was in #81172, which also landed in 1.52.

@jyn514
Copy link
Member Author

jyn514 commented Feb 22, 2021

Well, but I guess this is bad in general in case people use it in their own libraries.

@rustbot label: +beta-nominated

@rustbot rustbot added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Feb 22, 2021
@camelid
Copy link
Member

camelid commented Feb 22, 2021

Backport approval checklist:

@camelid
Copy link
Member

camelid commented Feb 22, 2021

cc @rust-lang/rustdoc for backport decision

@apiraino apiraino added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Feb 25, 2021
@cuviper cuviper mentioned this pull request Mar 11, 2021
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Mar 11, 2021
@cuviper cuviper modified the milestones: 1.52.0, 1.51.0 Mar 11, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 11, 2021
[beta] backports

This backports some beta-accepted PRs and one additional LLVM fix for s390x.

- rustdoc: treat edition 2021 as unstable rust-lang#82207
- Fix popping singleton paths in when generating E0433 rust-lang#82259
- libtest: Fix unwrap panic on duplicate TestDesc rust-lang#82274
- [intra-doc links] Don't check feature gates of items re-exported across crates rust-lang#82295
- rustdoc: Remove duplicate "List of all items" rust-lang#82484
- Substitute erased lifetimes on bad placeholder type rust-lang#82494
- Revert LLVM D81803 because it broke Windows 7 rust-lang#82605
- [SystemZ] Assign the full space for promoted and split outgoing args. rust-lang/llvm-project#95

r? `@Mark-Simulacrum`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. 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.

#![feature(intra_doc_pointers)] checks the active crate for a feature gate, not the original