Skip to content

rustdoc can't handle existential types #58624

Closed
@QuietMisdreavus

Description

@QuietMisdreavus
#![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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions