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

cargo doc: shows different return types for re-exported methods #115760

Closed
bheesham opened this issue Sep 11, 2023 · 2 comments · Fixed by #116084
Closed

cargo doc: shows different return types for re-exported methods #115760

bheesham opened this issue Sep 11, 2023 · 2 comments · Fixed by #116084
Assignees
Labels
A-async-await Area: Async & Await A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@bheesham
Copy link
Contributor

bheesham commented Sep 11, 2023

Running cargo doc for the async-net and smol repositories show different return types for async fn methods.

(Links to docs.rs provided below as a quick preview of the issue.)

git clone https://github.com/smol-rs/async-net.git && cd async-net && cargo doc --open && cd ..
git clone https://github.com/smol-rs/smol.git && cd smol && cargo doc --open && cd ..

Then browsing to the documentation for UdpSocket::bind in each, we see (using links from docs.rs):

async_net::UdpSocket::bind:

pub async fn bind<A: AsyncToSocketAddrs>(addr: A) -> Result<UdpSocket>

smol::UdpSocket::bind:

pub async fn bind<A>(addr: A) -> impl Future<Output = Result<UdpSocket, Error>> where
    A: AsyncToSocketAddrs,

I expected to see this happen: the same types should have been displayed.

Instead, this happened: smol's type is an async fn which returns a Future, which seems to conflict with async-net's definition.

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (030e4d382 2023-09-10)
binary: rustc
commit-hash: 030e4d382f1df30240408540f25cd1ccc8dbbf50
commit-date: 2023-09-10
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Some discussion: https://users.rust-lang.org/t/cargo-doc-shows-different-return-for-re-exported-methods/99687

@bheesham bheesham added the C-bug Category: This is a bug. label Sep 11, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 11, 2023
@steffahn
Copy link
Member

steffahn commented Sep 11, 2023

FYI, an IMO easier way to reproduce:

  • cargo new async_doc_repro; cd async_doc_repro; cargo add smol@=1.3.0; cargo doc --open
  • put UdpSocket::bind into the search bar
  • open at the first two results

It probably also would be nice to test if this can be reproduced using a minimal setup. E.g.: are multiple crates needed? Is publicly re-exporting (with doc(inline) of a whole crate essential, the way smol does for async_net or does re-exporting a module or a function do the same, too? Etc…

@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-async-await Area: Async & Await A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 12, 2023
@fmease
Copy link
Member

fmease commented Sep 12, 2023

Minimized:

// ––– a.rs –––   rustc a.rs --crate-type=lib --edition=2021
pub async fn f() -> i32 { 0 }

// ––– b.rs –––   rustdoc b.rs --edition=2021 --extern=a=liba.rlib
pub use a::*;

Rendered as pub async fn f() -> impl Future<Output = i32> instead of pub async fn f() -> i32 or pub fn f() -> impl Future<Output = i32>.

@fmease fmease added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Sep 12, 2023
@fmease fmease self-assigned this Sep 12, 2023
@bors bors closed this as completed in 0288f2e Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-cross-crate-reexports Area: Documentation that has been re-exported from a different crate C-bug Category: This is a bug. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants