rust-lang / rust-lang/rust

`mismatched types`: data type not inferred by compiler

Open
#122,184 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-coercions A-inference C-discussion T-types
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

fn main() {
    let arr = vec![1, 2, 3];
    let x1 = (&arr[0..0], &arr[0..0]);
    assert_eq!(x1, (&[], &[]));
}

compiler error:

mismatched types
expected tuple `(&[{integer}], &[{integer}])`
   found tuple `(&[_; 0], &[_; 0])`

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.

Research direction

Start by compiling the minimal Rust reproduction in the issue and confirm the reported mismatch between the inferred vector element type and the empty array literals. Trace the compiler's type inference and diagnostics for this case; done means determining the intended behavior and adding a regression test if a fix is appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.