Skip to content

Commit b7cfb6a

Browse files
committed
Improve debugging
1 parent 75b0a68 commit b7cfb6a

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/librustc_mir_build/hair/pattern/_match.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -1066,10 +1066,9 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
10661066
constructor: &Constructor<'tcx>,
10671067
ty: Ty<'tcx>,
10681068
) -> Self {
1069-
debug!("Fields::wildcards({:#?}, {:?})", constructor, ty);
10701069
let wildcard_from_ty = |ty| &*cx.pattern_arena.alloc(Pat::wildcard_from_ty(ty));
10711070

1072-
match constructor {
1071+
let ret = match constructor {
10731072
Single | Variant(_) => match ty.kind {
10741073
ty::Tuple(ref fs) => {
10751074
Fields::wildcards_from_tys(cx, fs.into_iter().map(|ty| ty.expect_ty()))
@@ -1129,7 +1128,9 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
11291128
_ => bug!("bad slice pattern {:?} {:?}", constructor, ty),
11301129
},
11311130
ConstantValue(..) | FloatRange(..) | IntRange(..) | NonExhaustive => Fields::empty(),
1132-
}
1131+
};
1132+
debug!("Fields::wildcards({:?}, {:?}) = {:#?}", constructor, ty, ret);
1133+
ret
11331134
}
11341135

11351136
fn len(&self) -> usize {
@@ -1870,7 +1871,7 @@ crate fn is_useful<'p, 'tcx>(
18701871

18711872
debug!("is_useful_expand_first_col: pcx={:#?}, expanding {:#?}", pcx, v.head());
18721873

1873-
if let Some(constructor) = pat_constructor(cx.tcx, cx.param_env, v.head()) {
1874+
let ret = if let Some(constructor) = pat_constructor(cx.tcx, cx.param_env, v.head()) {
18741875
debug!("is_useful - expanding constructor: {:#?}", constructor);
18751876
split_grouped_constructors(
18761877
cx.tcx,
@@ -1901,11 +1902,11 @@ crate fn is_useful<'p, 'tcx>(
19011902

19021903
let used_ctors: Vec<Constructor<'_>> =
19031904
matrix.heads().filter_map(|p| pat_constructor(cx.tcx, cx.param_env, p)).collect();
1904-
debug!("used_ctors = {:#?}", used_ctors);
1905+
debug!("is_useful_used_ctors = {:#?}", used_ctors);
19051906
// `all_ctors` are all the constructors for the given type, which
19061907
// should all be represented (or caught with the wild pattern `_`).
19071908
let all_ctors = all_constructors(cx, pcx);
1908-
debug!("all_ctors = {:#?}", all_ctors);
1909+
debug!("is_useful_all_ctors = {:#?}", all_ctors);
19091910

19101911
// `missing_ctors` is the set of constructors from the same type as the
19111912
// first column of `matrix` that are matched only by wildcard patterns
@@ -1920,7 +1921,7 @@ crate fn is_useful<'p, 'tcx>(
19201921
// can be big.
19211922
let missing_ctors = MissingConstructors::new(all_ctors, used_ctors);
19221923

1923-
debug!("missing_ctors.empty()={:#?}", missing_ctors.is_empty(),);
1924+
debug!("is_useful_missing_ctors.empty()={:#?}", missing_ctors.is_empty(),);
19241925

19251926
if missing_ctors.is_empty() {
19261927
let (all_ctors, _) = missing_ctors.into_inner();
@@ -1988,7 +1989,9 @@ crate fn is_useful<'p, 'tcx>(
19881989
usefulness.apply_missing_ctors(cx, pcx.ty, &missing_ctors)
19891990
}
19901991
}
1991-
}
1992+
};
1993+
debug!("is_useful::returns({:#?}, {:#?}) = {:?}", matrix, v, ret);
1994+
ret
19921995
}
19931996

19941997
/// A shorthand for the `U(S(c, P), S(c, q))` operation from the paper. I.e., `is_useful` applied
@@ -2647,7 +2650,10 @@ fn specialize_one_pattern<'p, 'tcx>(
26472650

26482651
PatKind::Or { .. } => bug!("Or-pattern should have been expanded earlier on."),
26492652
};
2650-
debug!("specialize({:#?}, {:#?}) = {:#?}", pat, ctor_wild_subpatterns, result);
2653+
debug!(
2654+
"specialize({:#?}, {:#?}, {:#?}) = {:#?}",
2655+
pat, constructor, ctor_wild_subpatterns, result
2656+
);
26512657

26522658
result
26532659
}

0 commit comments

Comments
 (0)