Skip to content

Inference failure since slice patterns does not serve as type expections #16609

Closed
@oxalica

Description

@oxalica

Types of a and b in this code below cannot be inferred by rust-analyzer, but it compiles fine with rustc.

// edition = "2021"
fn main() {
    let [a, b] = vec![1u32, 2u32].try_into().unwrap();
    //   ^ {unknown}
}

rust-analyzer version: 2024-02-19

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

relevant settings: N/A

Metadata

Metadata

Assignees

Labels

A-patternpattern handling related thingsA-tytype system / type inference / traits / method resolutionC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions