diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-01-09 16:31:04 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-01-09 16:32:17 +0100 |
| commit | 4a1889e3fd7dd3035c4892856be78e39977bbcc4 (patch) | |
| tree | c8e19c5d73db8bcca1c82f359a69c2b91becf075 /compiler/rustc_pattern_analysis/src/lints.rs | |
| parent | 5c65e9fdaf7a16d31291acd4c07c62efd8ceb460 (diff) | |
| download | rust-4a1889e3fd7dd3035c4892856be78e39977bbcc4.tar.gz rust-4a1889e3fd7dd3035c4892856be78e39977bbcc4.zip | |
Document the new `expand_and_push` method
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lints.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/lints.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_pattern_analysis/src/lints.rs b/compiler/rustc_pattern_analysis/src/lints.rs index 9b74c251d29..3af09a0b174 100644 --- a/compiler/rustc_pattern_analysis/src/lints.rs +++ b/compiler/rustc_pattern_analysis/src/lints.rs @@ -24,9 +24,9 @@ use crate::rustc::{ /// the depth of patterns, whereas `compute_exhaustiveness_and_usefulness` is worst-case exponential /// (exhaustiveness is NP-complete). The core difference is that we treat sub-columns separately. /// -/// This must not contain an or-pattern. `specialize` takes care to expand them. +/// This must not contain an or-pattern. `expand_and_push` takes care to expand them. /// -/// This is not used in the main algorithm; only in lints. +/// This is not used in the usefulness algorithm; only in lints. #[derive(Debug)] pub(crate) struct PatternColumn<'p, 'tcx> { patterns: Vec<&'p DeconstructedPat<'p, 'tcx>>, @@ -41,8 +41,10 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> { } column } + /// Pushes a pattern onto the column, expanding any or-patterns into its subpatterns. + /// Internal method, prefer [`PatternColumn::new`]. fn expand_and_push(&mut self, pat: PatOrWild<'p, RustcMatchCheckCtxt<'p, 'tcx>>) { - // We flatten or-patterns and skip wildcards + // We flatten or-patterns and skip algorithm-generated wildcards. if pat.is_or_pat() { self.patterns.extend( pat.flatten_or_pat().into_iter().filter_map(|pat_or_wild| pat_or_wild.as_pat()), |
