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 can't handle existential types #58624

Open
QuietMisdreavus opened this Issue Feb 21, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Feb 21, 2019

#![feature(existential_type)]

pub trait SomeTrait {
    fn some_fn(&self) {}
    
    type SomeType;
}

struct SomeStruct;

impl SomeTrait for SomeStruct {
    type SomeType = String;
}

pub existential type Asdf: SomeTrait;
pub fn asdf() -> Asdf { SomeStruct }

This sample compiles just fine, but when you run it in rustdoc...

$ rustdoc +nightly c.rs
error[E0277]: the trait bound `(): SomeTrait` is not satisfied
  --> c.rs:15:1
   |
15 | pub existential type Asdf: SomeTrait;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `SomeTrait` is not implemented for `()`
   |
   = note: the return type of a function must have a statically known size

error: Compilation failed, aborting rustdoc

$ rustdoc +nightly --version
rustdoc 1.34.0-nightly (f66e4697a 2019-02-20)

My personal guess is that the fact that rustdoc runs everybody_loops on the function that defines this type means that it no longer returns the actual type - instead it returns !, though the compiler picks up () for the error message.

@QuietMisdreavus

This comment has been minimized.

Copy link
Member Author

QuietMisdreavus commented Feb 21, 2019

cc #34511

@oli-obk

This comment has been minimized.

Copy link
Contributor

oli-obk commented Feb 21, 2019

The same thing happens for plain impl trait:

trait Foo {}

fn foo() -> impl Foo {
    loop {}
}

gives

error[E0277]: the trait bound `(): Foo` is not satisfied
 --> src/lib.rs:3:13
  |
3 | fn foo() -> impl Foo {
  |             ^^^^^^^^ the trait `Foo` is not implemented for `()`
  |
  = note: the return type of a function must have a statically known size

I'm not sure how to handle this, even if I turn on #![feature(never_type)], I get

error[E0277]: the trait bound `!: Foo` is not satisfied
 --> src/lib.rs:5:13
  |
5 | fn foo() -> impl Foo {
  |             ^^^^^^^^ the trait `Foo` is not implemented for `!`
  |
  = note: the return type of a function must have a statically known size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.