Skip to content

Rustdoc fails to compile compilable crates with #![feature(type_alias_impl_trait)] #75088

@WaffleLapkin

Description

@WaffleLapkin
Member

I was trying to use #![feature(type_alias_impl_trait)] in my crates, but I've recently found out that rustdoc fails to compile their doc (though cargo build compiles them just fine)

First example (playground):

#![feature(type_alias_impl_trait)]
use std::future::Future;

struct Ty;
trait Trait {
    type Fut;

    fn fut() -> Self::Fut;
}

impl Trait for Ty {
    type Fut = impl Future<Output = Ty>;

    fn fut() -> Self::Fut {
        async { Ty }
    }
}

cargo doc error:

% cargo doc
 Documenting rustfmt_brakes_because_of_futures v0.1.0 (/home/waffle/projects/repos/rustfmt_brakes_because_of_futures)
error[E0277]: `()` is not a future
  --> src/lib.rs:12:16
   |
12 |     type Fut = impl Future<Output = Ty>;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not a future
   |
   = help: the trait `std::future::Future` is not implemented for `()`
   = note: the return type of a function must have a statically known size

Second example (playground):

#![feature(type_alias_impl_trait)]
use std::future::Future;

struct Ty;
trait Trait {
    type Fut;

    // The `Option<>` is important here - without it it's essentially first example.
    // (in my original crates it was `Result` and nto option, but it doesn't change anything)
    fn fut() -> Option<Self::Fut>;
}

impl Trait for Ty {
    type Fut = impl Future<Output = Ty>;

    fn fut() -> Option<Self::Fut> {
        Some(async { Ty })
    }
}

cargo doc error:

% cargo doc
 Documenting rustfmt_brakes_because_of_futures v0.1.0 (/home/waffle/projects/repos/rustfmt_brakes_because_of_futures)
error: could not find defining uses
  --> src/lib.rs:12:16
   |
12 |     type Fut = impl Future<Output = Ty>;
   |                ^^^^^^^^^^^^^^^^^^^^^^^^

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (346aec9b0 2020-07-11)
binary: rustc
commit-hash: 346aec9b02f3c74f3fce97fd6bda24709d220e49
commit-date: 2020-07-11
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Aug 3, 2020
jyn514

jyn514 commented on Aug 3, 2020

@jyn514
Member

Both your examples work for me on master. This is a duplicate of #65863 which was fixed in #73566. Can you try updating nightly?

WaffleLapkin

WaffleLapkin commented on Aug 3, 2020

@WaffleLapkin
MemberAuthor

@jyn514 Oh. I've run rustup update yesterday, but it didn't update nightly for some reason (probably missing rustfmt?)

Yes, update of the nightly compiler fixed the issue for me, sorry for bothering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jonas-schievink@jyn514@WaffleLapkin

        Issue actions

          Rustdoc fails to compile compilable crates with `#![feature(type_alias_impl_trait)]` · Issue #75088 · rust-lang/rust