diff options
| author | Michael Goulet <michael@errs.io> | 2023-12-26 13:29:14 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-26 13:29:14 -0500 |
| commit | e1be642b41a79bd23b46aaa229cac4e23638b169 (patch) | |
| tree | 523210bd477925f28b5c6aca115973d79ef297c1 /compiler/rustc_pattern_analysis/src/lints.rs | |
| parent | 65aaece6c0d09ec0129088c6abc203612c9e39d0 (diff) | |
| parent | 48d089a8002d57f0c7b473905bc1925e99bcc76d (diff) | |
| download | rust-e1be642b41a79bd23b46aaa229cac4e23638b169.tar.gz rust-e1be642b41a79bd23b46aaa229cac4e23638b169.zip | |
Rollup merge of #119307 - compiler-errors:pat-lifetimes, r=Nadrieril
Clean up some lifetimes in `rustc_pattern_analysis` This PR removes some redundant lifetimes. I figured out that we were shortening the lifetime of an arena-allocated `&'p DeconstructedPat<'p>` to `'a DeconstructedPat<'p>`, which forced us to carry both lifetimes when we could otherwise carry just one. This PR also removes and elides some unnecessary lifetimes. I also cherry-picked 0292eb9bb9b897f5c0926c6a8530877f67e7cc9b, and then simplified more lifetimes in `MatchVisitor`, which should make #119233 a very simple PR! r? Nadrieril
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/lints.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/lints.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/compiler/rustc_pattern_analysis/src/lints.rs b/compiler/rustc_pattern_analysis/src/lints.rs index bba1f406056..6e5b0b04e1c 100644 --- a/compiler/rustc_pattern_analysis/src/lints.rs +++ b/compiler/rustc_pattern_analysis/src/lints.rs @@ -28,11 +28,11 @@ use crate::TypeCx; /// /// This is not used in the main algorithm; only in lints. #[derive(Debug)] -pub(crate) struct PatternColumn<'a, 'p, 'tcx> { - patterns: Vec<&'a DeconstructedPat<'p, 'tcx>>, +pub(crate) struct PatternColumn<'p, 'tcx> { + patterns: Vec<&'p DeconstructedPat<'p, 'tcx>>, } -impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> { +impl<'p, 'tcx> PatternColumn<'p, 'tcx> { pub(crate) fn new(arms: &[MatchArm<'p, 'tcx>]) -> Self { let mut patterns = Vec::with_capacity(arms.len()); for arm in arms { @@ -48,7 +48,7 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> { fn is_empty(&self) -> bool { self.patterns.is_empty() } - fn head_ty(&self, cx: MatchCtxt<'a, 'p, 'tcx>) -> Option<Ty<'tcx>> { + fn head_ty(&self, cx: MatchCtxt<'_, 'p, 'tcx>) -> Option<Ty<'tcx>> { if self.patterns.len() == 0 { return None; } @@ -64,7 +64,7 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> { pcx.ctors_for_ty().split(pcx, column_ctors) } - fn iter<'b>(&'b self) -> impl Iterator<Item = &'a DeconstructedPat<'p, 'tcx>> + Captures<'b> { + fn iter(&self) -> impl Iterator<Item = &'p DeconstructedPat<'p, 'tcx>> + Captures<'_> { self.patterns.iter().copied() } @@ -75,9 +75,9 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> { /// which may change the lengths. fn specialize( &self, - pcx: &PlaceCtxt<'a, 'p, 'tcx>, + pcx: &PlaceCtxt<'_, 'p, 'tcx>, ctor: &Constructor<'p, 'tcx>, - ) -> Vec<PatternColumn<'a, 'p, 'tcx>> { + ) -> Vec<PatternColumn<'p, 'tcx>> { let arity = ctor.arity(pcx); if arity == 0 { return Vec::new(); @@ -115,7 +115,7 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> { #[instrument(level = "debug", skip(cx), ret)] fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>( cx: MatchCtxt<'a, 'p, 'tcx>, - column: &PatternColumn<'a, 'p, 'tcx>, + column: &PatternColumn<'p, 'tcx>, ) -> Vec<WitnessPat<'p, 'tcx>> { let Some(ty) = column.head_ty(cx) else { return Vec::new(); @@ -163,7 +163,7 @@ fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>( pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>( cx: MatchCtxt<'a, 'p, 'tcx>, arms: &[MatchArm<'p, 'tcx>], - pat_column: &PatternColumn<'a, 'p, 'tcx>, + pat_column: &PatternColumn<'p, 'tcx>, scrut_ty: Ty<'tcx>, ) { let rcx: &RustcMatchCheckCtxt<'_, '_> = cx.tycx; @@ -216,7 +216,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>( #[instrument(level = "debug", skip(cx))] pub(crate) fn lint_overlapping_range_endpoints<'a, 'p, 'tcx>( cx: MatchCtxt<'a, 'p, 'tcx>, - column: &PatternColumn<'a, 'p, 'tcx>, + column: &PatternColumn<'p, 'tcx>, ) { let Some(ty) = column.head_ty(cx) else { return; |
