Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer/pat.rs')
| -rw-r--r-- | crates/hir-ty/src/infer/pat.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/hir-ty/src/infer/pat.rs b/crates/hir-ty/src/infer/pat.rs index 5ff22bea34..db93116f10 100644 --- a/crates/hir-ty/src/infer/pat.rs +++ b/crates/hir-ty/src/infer/pat.rs @@ -564,9 +564,10 @@ impl InferenceContext<'_> { | Pat::Range { .. } | Pat::Slice { .. } => true, Pat::Or(pats) => pats.iter().all(|p| self.is_non_ref_pat(body, *p)), - Pat::Path(p) => { - let v = self.resolve_value_path_inner(p, pat.into()); - v.is_some_and(|x| !matches!(x.0, hir_def::resolver::ValueNs::ConstId(_))) + Pat::Path(path) => { + // A const is a reference pattern, but other value ns things aren't (see #16131). + let resolved = self.resolve_value_path_inner(path, pat.into(), true); + resolved.is_some_and(|it| !matches!(it.0, hir_def::resolver::ValueNs::ConstId(_))) } Pat::ConstBlock(..) => false, Pat::Lit(expr) => !matches!( |