Skip to content

Is it a bug? #72943

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
heckad opened this issue Jun 3, 2020 · 1 comment
Closed

Is it a bug? #72943

heckad opened this issue Jun 3, 2020 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@heckad
Copy link
Contributor

heckad commented Jun 3, 2020

I tried this code:

fn get_numbers<T>() -> impl Iterator<Item=Result<i32, String>>
{
    unimplemented!()
}

I expected to see this happen: compile success

Instead, this happened:

error[E0277]: `()` is not an iterator
  --> src\main.rs:68:24
   |
68 | fn get_numbers<T>() -> impl Iterator<Item=Result<i32, String>>
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
69 | {
70 |     unimplemented!()
   |     ---------------- this returned value is of type `!`
   |
   = help: the trait `std::iter::Iterator` is not implemented for `()`
   = note: the return type of a function must have a statically known size

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (fe10f1a49 2020-06-02)
binary: rustc
commit-hash: fe10f1a49f5ca46e57261b95f46f519523f418fe
commit-date: 2020-06-02
host: x86_64-pc-windows-gnu
release: 1.45.0-nightly
LLVM version: 10.0

If you use templates then compile success.

fn get_numbers<T>() -> T
    where T: Iterator<Item=Result<i32, String>>
{
    unimplemented!()
}
@heckad heckad added the C-bug Category: This is a bug. label Jun 3, 2020
@jonas-schievink
Copy link
Contributor

Duplicate of #69882

@jonas-schievink jonas-schievink marked this as a duplicate of #69882 Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants