always check for mixed deref pattern and normal constructors

This makes it work for box patterns and in rust-analyzer.
This commit is contained in:
dianne
2025-07-04 21:17:40 -07:00
parent d98a5da813
commit 50061f3b11
8 changed files with 117 additions and 53 deletions

View File

@@ -8,6 +8,7 @@
#![allow(unused_crate_dependencies)]
// tidy-alphabetical-end
pub(crate) mod checks;
pub mod constructor;
#[cfg(feature = "rustc")]
pub mod errors;
@@ -107,6 +108,15 @@ pub trait PatCx: Sized + fmt::Debug {
_gapped_with: &[&DeconstructedPat<Self>],
) {
}
/// The current implementation of deref patterns requires that they can't match on the same
/// place as a normal constructor. Since this isn't caught by type-checking, we check it in the
/// `PatCx` before running the analysis. This reports an error if the check fails.
fn report_mixed_deref_pat_ctors(
&self,
deref_pat: &DeconstructedPat<Self>,
normal_pat: &DeconstructedPat<Self>,
) -> Self::Error;
}
/// The arm of a match expression.