Skip to content

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

Closed

Description

@bheesham

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 11, 2023
  2. steffahn commented on Sep 11, 2023

    @steffahn
    Member

    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…

  3. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crate
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Sep 12, 2023
  4. fmease commented on Sep 12, 2023

    @fmease
    Member

    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>.

  5. added
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    on Sep 12, 2023
  6. self-assigned this
    on Sep 12, 2023
  7. added a commit that references this issue on Sep 25, 2023
    0288f2e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitA-cross-crate-reexportsArea: Documentation that has been re-exported from a different crateC-bugCategory: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions