about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/lib.rs
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-07-26 01:15:04 -0500
committerGitHub <noreply@github.com>2025-07-26 01:15:04 -0500
commit3f7d497c8aba1b415c2b9b6a597eab1faa744416 (patch)
treebeb74b00c992ea03b7d3a6fc2188780cf3522c1b /compiler/rustc_pattern_analysis/src/lib.rs
parent9c13f4fb201e31f51ebaf8633ece12e660263008 (diff)
parentaf07c08c60fe779c2e73c561403cb5edf4f15e9b (diff)
downloadrust-3f7d497c8aba1b415c2b9b6a597eab1faa744416.tar.gz
rust-3f7d497c8aba1b415c2b9b6a597eab1faa744416.zip
Rollup merge of #144171 - Nadrieril:exhaustive-witnesses, r=davidtwco
pattern_analysis: add option to get a full set of witnesses

This adds an option to the rustc_pattern_analysis machinery to have it report a complete set of patterns when a match is non-exhaustive (by default we only guarantee to report _some_ missing patterns). This is for use in rust-analyzer.

Leaving as draft until I'm sure this is what r-a needs.

r? ghost
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lib.rs')
-rw-r--r--compiler/rustc_pattern_analysis/src/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs
index 66df35f9ee4..d9bb93a829b 100644
--- a/compiler/rustc_pattern_analysis/src/lib.rs
+++ b/compiler/rustc_pattern_analysis/src/lib.rs
@@ -57,6 +57,13 @@ pub trait PatCx: Sized + fmt::Debug {
 
     fn is_exhaustive_patterns_feature_on(&self) -> bool;
 
+    /// Whether to ensure the non-exhaustiveness witnesses we report for a complete set. This is
+    /// `false` by default to avoid some exponential blowup cases such as
+    /// <https://github.com/rust-lang/rust/issues/118437>.
+    fn exhaustive_witnesses(&self) -> bool {
+        false
+    }
+
     /// The number of fields for this constructor.
     fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize;