Skip to content

Type inference for todo!() breaks inside a tuple #100727

Description

@Storyyeller

Type inference for todo!() works if it is the sole element returned from a map closure, but breaks as soon as it is placed inside a tuple. playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1cfae6d57f44f603fa2eb258d332c7ab

I tried this code:

fn foo(_: Vec<(u32, String)>) {}


fn main() {
    foo((0..6).into_iter().map(|i| (i, todo!())).collect())
}

I expected to see this happen: compiles

Instead, this happened: compile error

error[E0277]: a value of type `Vec<(u32, String)>` cannot be built from an iterator over elements of type `({integer}, !)`
 --> src/main.rs:5:50
  |
5 |     foo((0..6).into_iter().map(|i| (i, todo!())).collect())
  |     ---                                          ^^^^^^^ value of type `Vec<(u32, String)>` cannot be built from `std::iter::Iterator<Item=({integer}, !)>`
  |     |
  |     required by a bound introduced by this call

Meta

I checked "nightly" on the playground and the same compile error happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions