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

Accept let-binding as a defining use of existential type #52653

Closed
dtolnay opened this issue Jul 23, 2018 · 5 comments
Closed

Accept let-binding as a defining use of existential type #52653

dtolnay opened this issue Jul 23, 2018 · 5 comments
Assignees

Comments

@dtolnay
Copy link
Member

dtolnay commented Jul 23, 2018

Per #52632 (comment), the following is expected to work. Currently it does not find the defining use of Clonable provided by the let binding.

#![feature(existential_type)]

existential type Clonable: Clone;

fn main() {
    let _x: Clonable = 0i32;
}
error[E0308]: mismatched types
 --> src/main.rs:6:24
  |
6 |     let _x: Clonable = 0i32;
  |                        ^^^^ expected anonymized type, found i32
  |
  = note: expected type `Clonable`
             found type `i32`

error: could not find defining uses
 --> src/main.rs:3:1
  |
3 | existential type Clonable: Clone;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

@oli-obk
Copy link
Contributor

oli-obk commented Jul 24, 2018

Yea I didn't even try to get that to work. I mean, we don't have let x: impl Debug = "foo"; and impl Trait is stable. This feature needs a whole new inference visitor in typeck. currently it's hard coded to only try filling out these types for return types

@oli-obk oli-obk self-assigned this Jan 25, 2019
@cramertj
Copy link
Member

All the examples in this thread seem to work now, so I'm closing this issue. Playground example.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 25, 2019

@oli-obk oli-obk reopened this Jan 25, 2019
@dtolnay
Copy link
Member Author

dtolnay commented Jan 25, 2019

Looks like it requires #![feature(impl_trait_in_bindings)].

@oli-obk
Copy link
Contributor

oli-obk commented Jan 25, 2019

Oh. There was a playground link. I should pay more attention before pressing buttons

@oli-obk oli-obk closed this as completed Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants