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 fails to compile existential associated types #58011

Closed
alecmocatta opened this issue Jan 30, 2019 · 3 comments
Closed

cargo doc fails to compile existential associated types #58011

alecmocatta opened this issue Jan 30, 2019 · 3 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@alecmocatta
Copy link
Contributor

While building, testing and running the below code works fine, cargo doc fails with:

error[E0277]: the trait bound `(): D` is not satisfied
  --> test_existential_doc_crash.rs:13:5
   |
13 |     existential type B: D;
   |     ^^^^^^^^^^^^^^^^^^^^^^ the trait `D` is not implemented for `()`
   |
   = note: the return type of a function must have a statically known size
#![feature(existential_type)]

pub trait A {
    type B: D;
    fn c() -> Self::B;
}

pub trait D {}
impl D for u8 {}

pub struct E;
impl A for E {
    existential type B: D;
    fn c() -> Self::B {
        0u8
    }
}
@jonas-schievink jonas-schievink added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. labels Jan 30, 2019
brunocodutra added a commit to brunocodutra/reducer that referenced this issue Feb 4, 2019
brunocodutra added a commit to brunocodutra/reducer that referenced this issue Feb 5, 2019
brunocodutra added a commit to brunocodutra/reducer that referenced this issue Feb 5, 2019
@rasendubi
Copy link
Contributor

This happens with non-associated types, too.

Here is a smaller example:

#![feature(existential_type)]

pub trait A {}
impl A for u8 {}

existential type T: A;

fn f() -> T {
    0u8
}
error[E0277]: the trait bound `(): A` is not satisfied
 --> test.rs:6:1
  |
6 | existential type T: A;
  | ^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `()`
  |
  = note: the return type of a function must have a statically known size

Basically, rustdoc treats all existential types as ().

@Centril Centril added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. labels Jul 28, 2019
@Nemo157
Copy link
Member

Nemo157 commented Aug 26, 2019

Updated example for type_alias_impl_trait (playground):

#![feature(type_alias_impl_trait)]

pub struct Foo;

impl std::iter::IntoIterator for Foo {
    type IntoIter = impl Iterator<Item = Self::Item>;
    type Item = ();

    fn into_iter(self) -> Self::IntoIter {
        Some(()).into_iter()
    }
}

pub type FooIntoIter = impl Iterator<Item = ()>;

pub fn foo_into_iter(foo: Foo) -> FooIntoIter {
    foo.into_iter()
}
error[E0277]: `()` is not an iterator
 --> src/lib.rs:6:5
  |
6 |     type IntoIter = impl Iterator<Item = Self::Item>;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
  |
  = help: the trait `std::iter::Iterator` is not implemented for `()`
  = note: the return type of a function must have a statically known size

error[E0277]: `()` is not an iterator
  --> src/lib.rs:14:1
   |
14 | pub type FooIntoIter = impl Iterator<Item = ()>;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
   |
   = help: the trait `std::iter::Iterator` is not implemented for `()`
   = note: the return type of a function must have a statically known size

@varkor
Copy link
Member

varkor commented Jan 12, 2020

Closing as a duplicate of #65863 (which has more information).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Development

No branches or pull requests

6 participants