rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

using feature exhaustive_patterns doesn't seem to work while rustc handle it

Open Stargateur opened this issue 3 years ago • 2 comments

rust-analyzer version: rust-analyzer version: 0.0.0 (5342f47f4 2022-07-09)

rustc version: rustc 1.62.0-nightly (52ca603da 2022-04-12)

#![feature(never_type)]
#![feature(exhaustive_patterns)]
use core::convert::Infallible;

fn foo() -> Result<(), !> {
    Ok(())
}

fn bar() -> Result<(), Infallible> {
    Ok(())
}

fn main() {
    match foo() {
        Ok(()) => println!("Ok"),
    }

    match bar() {
        Ok(()) => println!("Ok"),
    }
}

It seem rust-analizer have trouble with feature exhaustive_patterns.

Stargateur avatar Jul 13 '22 08:07 Stargateur

The concrete issue is that the second match is erroneously reported as non-exhaustive .


Related fixmes https://github.com/rust-lang/rust-analyzer/blob/4cbf23c192517cfebb0d754987aae95bc683b7a4/crates/hir-ty/src/diagnostics/match_check/usefulness.rs#L295-L299 https://github.com/rust-lang/rust-analyzer/blob/4cbf23c192517cfebb0d754987aae95bc683b7a4/crates/hir-ty/src/diagnostics/match_check/usefulness.rs#L314-L318

iDawer avatar Jul 13 '22 09:07 iDawer

I think I might also be running into the same issue in rust-lang/rust.

https://github.com/rust-lang/rust/blob/master/library/core/src/cell/once.rs#L125 produces a "Err(_) not covered" error in rust-analyzer as of the c9e134e1b609e571f4d7d18f91f0ccb1a0cb685d commit in rust-lang/rust. Not sure how to confirm exactly which version of rust-analyzer I'm using since I'm doing this via vscode on one of the foundation cloud desktops and am quite unfamiliar with this setup.

yaahc avatar Aug 01 '22 23:08 yaahc