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

Add RTN support to rustdoc #137956

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Mar 3, 2025

This adds support to rustdoc and rustdoc-json for rendering (..) RTN (return type notation) style generics.


Cleaning rustc_middle::ty::Ty is not correct still, though, and ends up rendering a function like:

pub fn foreign<T: Foreign<bar(..): Send>>()
where
    <T as Foreign>::bar(..): 'static,
    T::bar(..): Sync,

Into this:

pub fn foreign<T>()
where
    T: Foreign,
    impl Future<Output = ()>: Send + 'static + Sync,

This is because clean_middle_ty doesn't actually have sufficient context about whether the RPITIT is in its "defining scope" or not, so we don't know if the type was originally written like -> impl Trait or with RTN like T::method(..).

Partially addresses #123996 (i.e., HIR side, not middle::ty one)

@rustbot
Copy link
Collaborator

rustbot commented Mar 3, 2025

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 A-rustdoc-json Area: Rustdoc JSON backend A-rustdoc-search Area: Rustdoc's search feature S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Mar 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 3, 2025

rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing src/librustdoc/json/conversions.rs; otherwise, make sure you bump the FORMAT_VERSION constant.

cc @CraftSpider, @aDotInTheVoid, @Enselic, @obi1kenobi

Some changes occurred in tests/rustdoc-json

cc @aDotInTheVoid

@aDotInTheVoid aDotInTheVoid added F-return_type_notation `#[feature(return_type_notation)]` and removed A-rustdoc-search Area: Rustdoc's search feature T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Mar 3, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 3, 2025
…2, r=jieyouxu

triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search

This happened because `test/rustdoc-js` is a prefix of `test/rustdoc-json`, and triagebot works on prefixes.

Maybe this should be fixed in triagebot, but this works now.

This happened on rust-lang#137956 and rust-lang#137955.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 4, 2025
Rollup merge of rust-lang#137958 - aDotInTheVoid:aDotInTheVoid-patch-2, r=jieyouxu

triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search

This happened because `test/rustdoc-js` is a prefix of `test/rustdoc-json`, and triagebot works on prefixes.

Maybe this should be fixed in triagebot, but this works now.

This happened on rust-lang#137956 and rust-lang#137955.
@bors
Copy link
Contributor

bors commented Mar 7, 2025

☔ The latest upstream changes (presumably #138155) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -30,7 +30,7 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
/// This integer is incremented with every breaking change to the API,
/// and is returned along with the JSON blob as [`Crate::format_version`].
/// Consuming code should assert that this value matches the format version(s) that it supports.
pub const FORMAT_VERSION: u32 = 40;
pub const FORMAT_VERSION: u32 = 41;
Copy link
Member

Choose a reason for hiding this comment

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

This is taking place at the same time as #138109, which also (currently) makes the 40->41 change. Once one of these merges, the other should rebase then bump again. See #94591 for details.

@@ -30,7 +30,7 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
/// This integer is incremented with every breaking change to the API,
/// and is returned along with the JSON blob as [`Crate::format_version`].
/// Consuming code should assert that this value matches the format version(s) that it supports.
pub const FORMAT_VERSION: u32 = 40;
pub const FORMAT_VERSION: u32 = 41;
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
pub const FORMAT_VERSION: u32 = 41;
pub const FORMAT_VERSION: u32 = 42;

@fmease
Copy link
Member

fmease commented Mar 12, 2025

Sorry for the wait, looks good! r=me after rebase, version bump once #138109 is merged.

I'll keep #123996 open until we figure out the middle::ty situation (and I'll update its description) (also cc #113015).

@bors rollup

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 12, 2025
@fmease
Copy link
Member

fmease commented Mar 14, 2025

Blocking PR #138109 has been merged. Unblocked.

@fmease fmease removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Mar 14, 2025
@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Mar 15, 2025
@compiler-errors
Copy link
Member Author

bumped to version 42

@bors r=fmease

@bors
Copy link
Contributor

bors commented Mar 15, 2025

📌 Commit e3ac1fa 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 15, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Mar 16, 2025
Add RTN support to rustdoc

This adds support to rustdoc and rustdoc-json for rendering `(..)` RTN (return type notation) style generics.

---

Cleaning `rustc_middle::ty::Ty` is not correct still, though, and ends up rendering a function like:

```rust
pub fn foreign<T: Foreign<bar(..): Send>>()
where
    <T as Foreign>::bar(..): 'static,
    T::bar(..): Sync,
```

Into this:

```rust
pub fn foreign<T>()
where
    T: Foreign,
    impl Future<Output = ()>: Send + 'static + Sync,
```

This is because `clean_middle_ty` doesn't actually have sufficient context about whether the RPITIT is in its "defining scope" or not, so we don't know if the type was originally written like `-> impl Trait` or with RTN like `T::method(..)`.

Partially addresses rust-lang#123996 (i.e., HIR side, not middle::ty one)
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 16, 2025
Rollup of 16 pull requests

Successful merges:

 - rust-lang#133055 (Expand `CloneToUninit` documentation.)
 - rust-lang#137147 (Add exclude to config.toml)
 - rust-lang#137864 (Don't drop `Rvalue::WrapUnsafeBinder` during GVN)
 - rust-lang#137890 (doc: clarify that consume can be called after BufReader::peek)
 - rust-lang#137956 (Add RTN support to rustdoc)
 - rust-lang#137968 (Properly escape regexes in Python scripts)
 - rust-lang#138082 (Remove `#[cfg(not(test))]` gates in `core`)
 - rust-lang#138275 (expose `is_s390x_feature_detected!` from `std::arch`)
 - rust-lang#138303 (Fix Ptr inconsistency in {Rc,Arc})
 - rust-lang#138309 (Add missing doc for intrinsic (Fix PR135334))
 - rust-lang#138323 (Expand and organize `offset_of!` documentation.)
 - rust-lang#138329 (debug-assert that the size_hint is well-formed in `collect`)
 - rust-lang#138465 (linkchecker: bump html5ever)
 - rust-lang#138471 (Clean up some tests in tests/ui)
 - rust-lang#138472 (Add codegen test for rust-lang#129795)
 - rust-lang#138484 (Use lit span when suggesting suffix lit cast)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend F-return_type_notation `#[feature(return_type_notation)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants