diff options
| author | dianne <diannes.gm@gmail.com> | 2025-07-04 21:17:40 -0700 |
|---|---|---|
| committer | dianne <diannes.gm@gmail.com> | 2025-07-04 23:47:31 -0700 |
| commit | 50061f3b11f51d7a6e3acd8ce793a1f17f99b597 (patch) | |
| tree | 361e856dd3e167443f287dbf2a45d3e28ac28656 /compiler/rustc_pattern_analysis/src/usefulness.rs | |
| parent | d98a5da813da67eb189387b8ccfb73cf481275d8 (diff) | |
| download | rust-50061f3b11f51d7a6e3acd8ce793a1f17f99b597.tar.gz rust-50061f3b11f51d7a6e3acd8ce793a1f17f99b597.zip | |
always check for mixed deref pattern and normal constructors
This makes it work for box patterns and in rust-analyzer.
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/usefulness.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/usefulness.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index c348cd508f9..fb94b4afebb 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -720,7 +720,7 @@ use tracing::{debug, instrument}; use self::PlaceValidity::*; use crate::constructor::{Constructor, ConstructorSet, IntRange}; use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat}; -use crate::{MatchArm, PatCx, PrivateUninhabitedField}; +use crate::{MatchArm, PatCx, PrivateUninhabitedField, checks}; #[cfg(not(feature = "rustc"))] pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R { f() @@ -1836,6 +1836,9 @@ pub fn compute_match_usefulness<'p, Cx: PatCx>( scrut_validity: PlaceValidity, complexity_limit: usize, ) -> Result<UsefulnessReport<'p, Cx>, Cx::Error> { + // The analysis doesn't support deref patterns mixed with normal constructors; error if present. + checks::detect_mixed_deref_pat_ctors(tycx, arms)?; + let mut cx = UsefulnessCtxt { tycx, branch_usefulness: FxHashMap::default(), |
