Skip to content

Unexpected "cannot infer type" #140262

Open
Open
@Spxg

Description

@Spxg

I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=609d454db4ecdbe3026330593c586d79

// delete this import to compile success
use serde_json;

fn main() {
    let a = 0usize;
    let b = 0i32;
    assert!(a == b as _);
}

I expected to see this happen: can infer type

Instead, this happened: cannot infer type, but delete use serde_json; will compile success

In fact, if the compilation succeeds at this point, it may be broken later when used with other dependencies. Spxg/sqlite-wasm-rs#58

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceC-bugCategory: This is a bug.T-compilerRelevant to the compiler 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