Skip to content

unimplemented!() not working with -> impl Trait #47367

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

Closed
ghost opened this issue Jan 11, 2018 · 3 comments
Closed

unimplemented!() not working with -> impl Trait #47367

ghost opened this issue Jan 11, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 11, 2018

This is a bit annoying:

#![feature(conservative_impl_trait, universal_impl_trait)]

fn running_count(iter: impl Iterator<Item = u32>) -> impl Iterator<Item = u32> {
    unimplemented!()
}

fn main() {}
error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied
 --> src/main.rs:3:54
  |
3 | fn running_count(iter: impl Iterator<Item = u32>) -> impl Iterator<Item = u32> {
  |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method
  |
  = help: the trait `std::iter::Iterator` is not implemented for `()`
  = note: the return type of a function must have a statically known size
@varkor
Copy link
Member

varkor commented Jan 11, 2018

Similarly (which I think is the root cause), this fails:

#![crate_type = "lib"]
#![feature(conservative_impl_trait, universal_impl_trait)]
#![feature(never_type)]

trait T {}

fn f(x: !) -> impl T {
    x      // ^^^^^^ the trait `T` is not implemented for `!`
}

I.e. ! cannot be coerced into impl Trait for any trait.

@Cobrand
Copy link
Contributor

Cobrand commented Jan 12, 2018

This is a duplicate of #36375

@sfackler
Copy link
Member

Closing in favor of #36375.

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