Skip to content

Fails to parse existential type in statement position #52631

Closed
@dtolnay

Description

@dtolnay

As of rustc 1.29.0-nightly (874dec2 2018-07-21) the following works:

#![feature(existential_type)]

use std::fmt::Debug;

existential type Existential: Debug;

fn main() {
    fn f() -> Existential {}
    println!("{:?}", f());
}

But the following does not parse. I would expect this to be equivalent to the above except for Existential in scope just within main, but if this is disallowed by the RFC then it should produce a better error message.

#![feature(existential_type)]

use std::fmt::Debug;

fn main() {
    existential type Existential: Debug;

    fn f() -> Existential {}
    println!("{:?}", f());
}
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `type`
 --> src/main.rs:6:17
  |
6 |     existential type Existential: Debug;
  |                 ^^^^ expected one of 8 possible tokens here

error[E0425]: cannot find value `existential` in this scope
 --> src/main.rs:6:5
  |
6 |     existential type Existential: Debug;
  |     ^^^^^^^^^^^ not found in this scope

Mentioning the existential types tracking issue #34511
Mentioning @oli-obk and @cramertj

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions