Skip to content

Commit 4a1889e

Browse files
committed
Document the new expand_and_push method
1 parent 5c65e9f commit 4a1889e

File tree

1 file changed

+5
-3
lines changed
  • compiler/rustc_pattern_analysis/src

1 file changed

+5
-3
lines changed

compiler/rustc_pattern_analysis/src/lints.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use crate::rustc::{
2424
/// the depth of patterns, whereas `compute_exhaustiveness_and_usefulness` is worst-case exponential
2525
/// (exhaustiveness is NP-complete). The core difference is that we treat sub-columns separately.
2626
///
27-
/// This must not contain an or-pattern. `specialize` takes care to expand them.
27+
/// This must not contain an or-pattern. `expand_and_push` takes care to expand them.
2828
///
29-
/// This is not used in the main algorithm; only in lints.
29+
/// This is not used in the usefulness algorithm; only in lints.
3030
#[derive(Debug)]
3131
pub(crate) struct PatternColumn<'p, 'tcx> {
3232
patterns: Vec<&'p DeconstructedPat<'p, 'tcx>>,
@@ -41,8 +41,10 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
4141
}
4242
column
4343
}
44+
/// Pushes a pattern onto the column, expanding any or-patterns into its subpatterns.
45+
/// Internal method, prefer [`PatternColumn::new`].
4446
fn expand_and_push(&mut self, pat: PatOrWild<'p, RustcMatchCheckCtxt<'p, 'tcx>>) {
45-
// We flatten or-patterns and skip wildcards
47+
// We flatten or-patterns and skip algorithm-generated wildcards.
4648
if pat.is_or_pat() {
4749
self.patterns.extend(
4850
pat.flatten_or_pat().into_iter().filter_map(|pat_or_wild| pat_or_wild.as_pat()),

0 commit comments

Comments
 (0)