rust-lang/rust-analyzer · error

not implemented

Error message

not implemented

What it means

An `unimplemented!()` panic inside the match exhaustiveness lowering/hoisting code: `hoist_witness_pat` encountered a `WitnessPat` constructor kind it has no arm for when converting the deconstructed witness pattern back into a `Pat`. It means the pattern-analysis state machine reached a case the hoisting side never implemented (the lowering side supports more constructors than hoisting).

Source

Thrown at crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:254

            }
            PatKind::Or { pats } => {
                ctor = Or;
                fields = pats
                    .iter()
                    .enumerate()
                    .map(|(i, pat)| self.lower_pat(pat).at_index(i))
                    .collect();
                arity = pats.len();
            }
        }
        DeconstructedPat::new(ctor, fields, arity, pat.ty, ())
    }

    pub(crate) fn hoist_witness_pat(&self, pat: &WitnessPat<'a, 'db>) -> Pat<'db> {
        let mut subpatterns = pat.iter_fields().map(|p| self.hoist_witness_pat(p));
        let kind = match pat.ctor() {
            &Bool(value) => PatKind::LiteralBool { value },
            IntRange(_) => unimplemented!(),
            Struct | Variant(_) | UnionField => match pat.ty().kind() {
                TyKind::Tuple(..) => PatKind::Leaf {
                    subpatterns: subpatterns
                        .zip(0u32..)
                        .map(|(p, i)| FieldPat {
                            field: LocalFieldId::from_raw(i.into()),
                            pattern: p,
                        })
                        .collect(),
                },
                TyKind::Adt(adt, substs) => {
                    let variant =
                        Self::variant_id_for_adt(self.db, pat.ctor(), adt.def_id()).unwrap();
                    let subpatterns = self
                        .list_variant_fields(*pat.ty(), variant)
                        .zip(subpatterns)
                        .map(|((field, _ty), pattern)| FieldPat { field, pattern })
                        .collect();

View on GitHub (pinned to e8f7e90aa3)

Solutions

  1. Find which `WitnessPat` constructor (e.g. wildcard, ascribe, or newer ctor kinds added to lowering) lacks a matching arm in `hoist_witness_pat` and add a hoisting branch for it
  2. Fall back to a wildcard pattern for the unhandled constructor instead of panicking, since a witness is only advisory output for missing-match diagnostics
  3. Reproduce with a match that triggers the missing arm and add a regression test in the match_check fixture suite
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:254 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rust-lang/rust-analyzer@e8f7e90aa3 (2026-09-03). Data as JSON: /api/errors/e77834f1a70ce909. Report an issue: GitHub.