Skip to content

False positive E0005 non-exhaustive pattern when using impl_trait_in_assoc_type #17702

Open
@kpreid

Description

@kpreid

rust-analyzer version: 0.3.2045-standalone (4afe0d5 2024-07-21)

rustc version: rustc 1.82.0-nightly (c1a6199e9 2024-07-24)

editor or extension: VSCode, extension v0.3.2045

code snippet to reproduce:

#![feature(impl_trait_in_assoc_type)]

pub trait Traitor {
    type Assoc;
    const FOO: Self::Assoc;
    fn commit(&self, check: Self::Assoc);
}

pub struct Imp {}
struct Concrete {}

impl Traitor for Imp {
    type Assoc = impl Sized;

    const FOO: Self::Assoc = Concrete {};

    fn commit(&self, check: Self::Assoc) {
        let Concrete {} = check;
        //  ^^^^^^^^^^^ non-exhaustive pattern: `_` not covered
    }
}

Existing issue #17031 is another false positive of this diagnostic, but it is related to an impl hidden in a const block, rather than an ATPIT.

@rustbot label +A-pattern

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-patternpattern handling related thingsC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions