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

Closed
QuietMisdreavus opened this issue Feb 21, 2019 · 4 comments
Closed

rustdoc can't handle existential types #58624

QuietMisdreavus opened this issue Feb 21, 2019 · 4 comments

Comments

@QuietMisdreavus
Copy link
Member

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

@QuietMisdreavus QuietMisdreavus commented Feb 21, 2019

cc #34511

@oli-obk
Copy link
Contributor

@oli-obk 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
@alecmocatta
Copy link
Contributor

@alecmocatta alecmocatta commented Aug 26, 2019

see also #58011

@varkor
Copy link
Member

@varkor varkor commented Jan 12, 2020

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

@varkor varkor closed this Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants