Skip to content

Commit 8cf2c0d

Browse files
committed
Improve debugging experience
1 parent 204805a commit 8cf2c0d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

compiler/rustc_pattern_analysis/src/constructor.rs

-1
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ impl<Cx: PatCx> ConstructorSet<Cx> {
974974
/// any) are missing; 2/ split constructors to handle non-trivial intersections e.g. on ranges
975975
/// or slices. This can get subtle; see [`SplitConstructorSet`] for details of this operation
976976
/// and its invariants.
977-
#[instrument(level = "debug", skip(self, ctors), ret)]
978977
pub fn split<'a>(
979978
&self,
980979
ctors: impl Iterator<Item = &'a Constructor<Cx>> + Clone,

compiler/rustc_pattern_analysis/src/rustc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
186186

187187
/// Returns the types of the fields for a given constructor. The result must have a length of
188188
/// `ctor.arity()`.
189-
#[instrument(level = "trace", skip(self))]
190189
pub(crate) fn ctor_sub_tys<'a>(
191190
&'a self,
192191
ctor: &'a Constructor<'p, 'tcx>,
@@ -283,7 +282,6 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
283282
/// Creates a set that represents all the constructors of `ty`.
284283
///
285284
/// See [`crate::constructor`] for considerations of emptiness.
286-
#[instrument(level = "debug", skip(self), ret)]
287285
pub fn ctors_for_ty(
288286
&self,
289287
ty: RevealedTy<'tcx>,

compiler/rustc_pattern_analysis/src/usefulness.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,14 @@ impl<Cx: PatCx> PlaceInfo<Cx> {
871871
where
872872
Cx: 'a,
873873
{
874+
debug!(?self.ty);
874875
if self.private_uninhabited {
875876
// Skip the whole column
876877
return Ok((smallvec![Constructor::PrivateUninhabited], vec![]));
877878
}
878879

879880
let ctors_for_ty = cx.ctors_for_ty(&self.ty)?;
881+
debug!(?ctors_for_ty);
880882

881883
// We treat match scrutinees of type `!` or `EmptyEnum` differently.
882884
let is_toplevel_exception =
@@ -895,6 +897,7 @@ impl<Cx: PatCx> PlaceInfo<Cx> {
895897

896898
// Analyze the constructors present in this column.
897899
let mut split_set = ctors_for_ty.split(ctors);
900+
debug!(?split_set);
898901
let all_missing = split_set.present.is_empty();
899902

900903
// Build the set of constructors we will specialize with. It must cover the whole type, so
@@ -1254,7 +1257,7 @@ impl<'p, Cx: PatCx> Matrix<'p, Cx> {
12541257
/// + true + [Second(true)] +
12551258
/// + false + [_] +
12561259
/// + _ + [_, _, tail @ ..] +
1257-
/// | ✓ | ? | // column validity
1260+
/// | ✓ | ? | // validity
12581261
/// ```
12591262
impl<'p, Cx: PatCx> fmt::Debug for Matrix<'p, Cx> {
12601263
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -1285,7 +1288,7 @@ impl<'p, Cx: PatCx> fmt::Debug for Matrix<'p, Cx> {
12851288
write!(f, " {sep}")?;
12861289
}
12871290
if is_validity_row {
1288-
write!(f, " // column validity")?;
1291+
write!(f, " // validity")?;
12891292
}
12901293
write!(f, "\n")?;
12911294
}
@@ -1617,7 +1620,6 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: PatCx>(
16171620
};
16181621

16191622
// Analyze the constructors present in this column.
1620-
debug!("ty: {:?}", place.ty);
16211623
let ctors = matrix.heads().map(|p| p.ctor());
16221624
let (split_ctors, missing_ctors) = place.split_column_ctors(mcx.tycx, ctors)?;
16231625

@@ -1669,7 +1671,10 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: PatCx>(
16691671
for row in matrix.rows() {
16701672
if row.useful {
16711673
if let PatOrWild::Pat(pat) = row.head() {
1672-
mcx.useful_subpatterns.insert(pat.uid);
1674+
let newly_useful = mcx.useful_subpatterns.insert(pat.uid);
1675+
if newly_useful {
1676+
debug!("newly useful: {pat:?}");
1677+
}
16731678
}
16741679
}
16751680
}
@@ -1768,6 +1773,7 @@ pub fn compute_match_usefulness<'p, Cx: PatCx>(
17681773
.map(|arm| {
17691774
debug!(?arm);
17701775
let usefulness = collect_pattern_usefulness(&cx.useful_subpatterns, arm.pat);
1776+
debug!(?usefulness);
17711777
(arm, usefulness)
17721778
})
17731779
.collect();

0 commit comments

Comments
 (0)