rust-lang / rust-lang/rust

Unexpected "cannot infer type"

Open
#140,262 2 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

A-diagnostics A-inference C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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. https://github.com/Spxg/sqlite-wasm-rs/issues/58

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.