Skip to content

Existential types: Unused closure environment is part of concrete type #57678

Closed
@zroug

Description

@zroug

Compare

#![feature(existential_type)]

existential type T: ;
fn test(_unused: impl Copy) -> T {
    || {}
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=194cca6bdb23ec0b634bc01dea43abd4

which results in error: type parameter `impl Copy` is part of concrete type but not used in parameter list for existential type to

#![feature(existential_type)]

existential type T: ;
fn test(_unused: impl Copy) -> T {
    fn workaround() -> impl Fn() {
        || {}
    }
    workaround()
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=23789461920ea49d85042a9604f86f97

which compiles fine.

There are quite a few open issues for existential types so I hope I haven't overlooked a duplicate. #42940 might be related.

Meta

rustc 1.33.0-nightly (03acbd71c 2019-01-14)
binary: rustc
commit-hash: 03acbd71c977cd63ce5f39ba9b6fe9ffd578785a
commit-date: 2019-01-14
host: x86_64-unknown-linux-gnu
release: 1.33.0-nightly
LLVM version: 8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-type-systemArea: Type system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions