pattern_analysis: add option to get a full set of witnesses
This commit is contained in:
@@ -950,9 +950,7 @@ impl<Cx: PatCx> Constructor<Cx> {
|
||||
}
|
||||
}
|
||||
Never => write!(f, "!")?,
|
||||
Wildcard | Missing | NonExhaustive | Hidden | PrivateUninhabited => {
|
||||
write!(f, "_ : {:?}", ty)?
|
||||
}
|
||||
Wildcard | Missing | NonExhaustive | Hidden | PrivateUninhabited => write!(f, "_")?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1747,7 +1747,9 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: PatCx>(
|
||||
// `ctor` is *irrelevant* if there's another constructor in `split_ctors` that matches
|
||||
// strictly fewer rows. In that case we can sometimes skip it. See the top of the file for
|
||||
// details.
|
||||
let ctor_is_relevant = matches!(ctor, Constructor::Missing) || missing_ctors.is_empty();
|
||||
let ctor_is_relevant = matches!(ctor, Constructor::Missing)
|
||||
|| missing_ctors.is_empty()
|
||||
|| mcx.tycx.exhaustive_witnesses();
|
||||
let mut spec_matrix = matrix.specialize_constructor(pcx, &ctor, ctor_is_relevant)?;
|
||||
let mut witnesses = ensure_sufficient_stack(|| {
|
||||
compute_exhaustiveness_and_usefulness(mcx, &mut spec_matrix)
|
||||
|
||||
Reference in New Issue
Block a user