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

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

Closed
WaffleLapkin opened this issue Aug 3, 2020 · 2 comments
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@WaffleLapkin
Copy link
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
@WaffleLapkin WaffleLapkin added the C-bug Category: This is a bug. label Aug 3, 2020
@jonas-schievink jonas-schievink added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 3, 2020
@jyn514
Copy link
Member

jyn514 commented Aug 3, 2020

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
Copy link
Member Author

@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
Labels
C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Development

No branches or pull requests

3 participants