Skip to content

Cannot infer type for [], but only when serde_json is used (?) #89254

Open
@m-ou-se

Description

@m-ou-se
extern crate serde_json; // Code works fine if you remove this line.

fn main() {
    Vec::<u8>::new() == [];
}

That produces:

error[E0282]: type annotations needed
 --> src/main.rs:4:25
  |
4 |     Vec::<u8>::new() == [];
  |                         ^^ cannot infer type

Somehow, referencing serde_json makes rustc unable to infer some type here. This happens on both the current stable and nightly versions of Rust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language 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