Skip to content

Commit eebb2ab

Browse files
Yeet some lifetimes
1 parent e4c626d commit eebb2ab

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

compiler/rustc_pattern_analysis/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct MatchCtxt<'a, 'p, Cx: TypeCx> {
9191
/// The context for type information.
9292
pub tycx: &'a Cx,
9393
/// An arena to store the wildcards we produce during analysis.
94-
pub wildcard_arena: &'a TypedArena<DeconstructedPat<'p, Cx>>,
94+
pub wildcard_arena: &'p TypedArena<DeconstructedPat<'p, Cx>>,
9595
}
9696

9797
/// The arm of a match expression.

compiler/rustc_pattern_analysis/src/lints.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ use crate::TypeCx;
2828
///
2929
/// This is not used in the main algorithm; only in lints.
3030
#[derive(Debug)]
31-
pub(crate) struct PatternColumn<'a, 'p, 'tcx> {
32-
patterns: Vec<&'a DeconstructedPat<'p, 'tcx>>,
31+
pub(crate) struct PatternColumn<'p, 'tcx> {
32+
patterns: Vec<&'p DeconstructedPat<'p, 'tcx>>,
3333
}
3434

35-
impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
35+
impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
3636
pub(crate) fn new(arms: &[MatchArm<'p, 'tcx>]) -> Self {
3737
let mut patterns = Vec::with_capacity(arms.len());
3838
for arm in arms {
@@ -48,7 +48,7 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
4848
fn is_empty(&self) -> bool {
4949
self.patterns.is_empty()
5050
}
51-
fn head_ty(&self, cx: MatchCtxt<'a, 'p, 'tcx>) -> Option<Ty<'tcx>> {
51+
fn head_ty(&self, cx: MatchCtxt<'_, 'p, 'tcx>) -> Option<Ty<'tcx>> {
5252
if self.patterns.len() == 0 {
5353
return None;
5454
}
@@ -64,7 +64,7 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
6464
pcx.ctors_for_ty().split(pcx, column_ctors)
6565
}
6666

67-
fn iter<'b>(&'b self) -> impl Iterator<Item = &'a DeconstructedPat<'p, 'tcx>> + Captures<'b> {
67+
fn iter<'b>(&'b self) -> impl Iterator<Item = &'p DeconstructedPat<'p, 'tcx>> + Captures<'b> {
6868
self.patterns.iter().copied()
6969
}
7070

@@ -75,9 +75,9 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
7575
/// which may change the lengths.
7676
fn specialize(
7777
&self,
78-
pcx: &PlaceCtxt<'a, 'p, 'tcx>,
78+
pcx: &PlaceCtxt<'_, 'p, 'tcx>,
7979
ctor: &Constructor<'p, 'tcx>,
80-
) -> Vec<PatternColumn<'a, 'p, 'tcx>> {
80+
) -> Vec<PatternColumn<'p, 'tcx>> {
8181
let arity = ctor.arity(pcx);
8282
if arity == 0 {
8383
return Vec::new();
@@ -115,7 +115,7 @@ impl<'a, 'p, 'tcx> PatternColumn<'a, 'p, 'tcx> {
115115
#[instrument(level = "debug", skip(cx), ret)]
116116
fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
117117
cx: MatchCtxt<'a, 'p, 'tcx>,
118-
column: &PatternColumn<'a, 'p, 'tcx>,
118+
column: &PatternColumn<'p, 'tcx>,
119119
) -> Vec<WitnessPat<'p, 'tcx>> {
120120
let Some(ty) = column.head_ty(cx) else {
121121
return Vec::new();
@@ -163,7 +163,7 @@ fn collect_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
163163
pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
164164
cx: MatchCtxt<'a, 'p, 'tcx>,
165165
arms: &[MatchArm<'p, 'tcx>],
166-
pat_column: &PatternColumn<'a, 'p, 'tcx>,
166+
pat_column: &PatternColumn<'p, 'tcx>,
167167
scrut_ty: Ty<'tcx>,
168168
) {
169169
let rcx: &RustcMatchCheckCtxt<'_, '_> = cx.tycx;
@@ -216,7 +216,7 @@ pub(crate) fn lint_nonexhaustive_missing_variants<'a, 'p, 'tcx>(
216216
#[instrument(level = "debug", skip(cx))]
217217
pub(crate) fn lint_overlapping_range_endpoints<'a, 'p, 'tcx>(
218218
cx: MatchCtxt<'a, 'p, 'tcx>,
219-
column: &PatternColumn<'a, 'p, 'tcx>,
219+
column: &PatternColumn<'p, 'tcx>,
220220
) {
221221
let Some(ty) = column.head_ty(cx) else {
222222
return;

compiler/rustc_pattern_analysis/src/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'p, Cx: TypeCx> DeconstructedPat<'p, Cx> {
8383
&self,
8484
pcx: &PlaceCtxt<'a, 'p, Cx>,
8585
other_ctor: &Constructor<Cx>,
86-
) -> SmallVec<[&'a DeconstructedPat<'p, Cx>; 2]> {
86+
) -> SmallVec<[&'p DeconstructedPat<'p, Cx>; 2]> {
8787
let wildcard_sub_tys = || {
8888
let tys = pcx.ctor_sub_tys(other_ctor);
8989
tys.iter()

compiler/rustc_pattern_analysis/src/usefulness.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -826,17 +826,17 @@ impl fmt::Display for ValidityConstraint {
826826
// - Cx global compilation context
827827
#[derive(derivative::Derivative)]
828828
#[derivative(Clone(bound = ""))]
829-
struct PatStack<'a, 'p, Cx: TypeCx> {
829+
struct PatStack<'p, Cx: TypeCx> {
830830
// Rows of len 1 are very common, which is why `SmallVec[_; 2]` works well.
831-
pats: SmallVec<[&'a DeconstructedPat<'p, Cx>; 2]>,
831+
pats: SmallVec<[&'p DeconstructedPat<'p, Cx>; 2]>,
832832
/// Sometimes we know that as far as this row is concerned, the current case is already handled
833833
/// by a different, more general, case. When the case is irrelevant for all rows this allows us
834834
/// to skip a case entirely. This is purely an optimization. See at the top for details.
835835
relevant: bool,
836836
}
837837

838-
impl<'a, 'p, Cx: TypeCx> PatStack<'a, 'p, Cx> {
839-
fn from_pattern(pat: &'a DeconstructedPat<'p, Cx>) -> Self {
838+
impl<'a, 'p, Cx: TypeCx> PatStack<'p, Cx> {
839+
fn from_pattern(pat: &'p DeconstructedPat<'p, Cx>) -> Self {
840840
PatStack { pats: smallvec![pat], relevant: true }
841841
}
842842

@@ -848,17 +848,17 @@ impl<'a, 'p, Cx: TypeCx> PatStack<'a, 'p, Cx> {
848848
self.pats.len()
849849
}
850850

851-
fn head(&self) -> &'a DeconstructedPat<'p, Cx> {
851+
fn head(&self) -> &'p DeconstructedPat<'p, Cx> {
852852
self.pats[0]
853853
}
854854

855-
fn iter<'b>(&'b self) -> impl Iterator<Item = &'a DeconstructedPat<'p, Cx>> + Captures<'b> {
855+
fn iter<'b>(&'b self) -> impl Iterator<Item = &'p DeconstructedPat<'p, Cx>> + Captures<'b> {
856856
self.pats.iter().copied()
857857
}
858858

859859
// Recursively expand the first or-pattern into its subpatterns. Only useful if the pattern is
860860
// an or-pattern. Panics if `self` is empty.
861-
fn expand_or_pat<'b>(&'b self) -> impl Iterator<Item = PatStack<'a, 'p, Cx>> + Captures<'b> {
861+
fn expand_or_pat<'b>(&'b self) -> impl Iterator<Item = PatStack<'p, Cx>> + Captures<'b> {
862862
self.head().flatten_or_pat().into_iter().map(move |pat| {
863863
let mut new = self.clone();
864864
new.pats[0] = pat;
@@ -873,7 +873,7 @@ impl<'a, 'p, Cx: TypeCx> PatStack<'a, 'p, Cx> {
873873
pcx: &PlaceCtxt<'a, 'p, Cx>,
874874
ctor: &Constructor<Cx>,
875875
ctor_is_relevant: bool,
876-
) -> PatStack<'a, 'p, Cx> {
876+
) -> PatStack<'p, Cx> {
877877
// We pop the head pattern and push the new fields extracted from the arguments of
878878
// `self.head()`.
879879
let mut new_pats = self.head().specialize(pcx, ctor);
@@ -886,7 +886,7 @@ impl<'a, 'p, Cx: TypeCx> PatStack<'a, 'p, Cx> {
886886
}
887887
}
888888

889-
impl<'a, 'p, Cx: TypeCx> fmt::Debug for PatStack<'a, 'p, Cx> {
889+
impl<'p, Cx: TypeCx> fmt::Debug for PatStack<'p, Cx> {
890890
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
891891
// We pretty-print similarly to the `Debug` impl of `Matrix`.
892892
write!(f, "+")?;
@@ -899,9 +899,9 @@ impl<'a, 'p, Cx: TypeCx> fmt::Debug for PatStack<'a, 'p, Cx> {
899899

900900
/// A row of the matrix.
901901
#[derive(Clone)]
902-
struct MatrixRow<'a, 'p, Cx: TypeCx> {
902+
struct MatrixRow<'p, Cx: TypeCx> {
903903
// The patterns in the row.
904-
pats: PatStack<'a, 'p, Cx>,
904+
pats: PatStack<'p, Cx>,
905905
/// Whether the original arm had a guard. This is inherited when specializing.
906906
is_under_guard: bool,
907907
/// When we specialize, we remember which row of the original matrix produced a given row of the
@@ -914,7 +914,7 @@ struct MatrixRow<'a, 'p, Cx: TypeCx> {
914914
useful: bool,
915915
}
916916

917-
impl<'a, 'p, Cx: TypeCx> MatrixRow<'a, 'p, Cx> {
917+
impl<'a, 'p, Cx: TypeCx> MatrixRow<'p, Cx> {
918918
fn is_empty(&self) -> bool {
919919
self.pats.is_empty()
920920
}
@@ -923,17 +923,17 @@ impl<'a, 'p, Cx: TypeCx> MatrixRow<'a, 'p, Cx> {
923923
self.pats.len()
924924
}
925925

926-
fn head(&self) -> &'a DeconstructedPat<'p, Cx> {
926+
fn head(&self) -> &'p DeconstructedPat<'p, Cx> {
927927
self.pats.head()
928928
}
929929

930-
fn iter<'b>(&'b self) -> impl Iterator<Item = &'a DeconstructedPat<'p, Cx>> + Captures<'b> {
930+
fn iter<'b>(&'b self) -> impl Iterator<Item = &'p DeconstructedPat<'p, Cx>> + Captures<'b> {
931931
self.pats.iter()
932932
}
933933

934934
// Recursively expand the first or-pattern into its subpatterns. Only useful if the pattern is
935935
// an or-pattern. Panics if `self` is empty.
936-
fn expand_or_pat<'b>(&'b self) -> impl Iterator<Item = MatrixRow<'a, 'p, Cx>> + Captures<'b> {
936+
fn expand_or_pat<'b>(&'b self) -> impl Iterator<Item = MatrixRow<'p, Cx>> + Captures<'b> {
937937
self.pats.expand_or_pat().map(|patstack| MatrixRow {
938938
pats: patstack,
939939
parent_row: self.parent_row,
@@ -950,7 +950,7 @@ impl<'a, 'p, Cx: TypeCx> MatrixRow<'a, 'p, Cx> {
950950
ctor: &Constructor<Cx>,
951951
ctor_is_relevant: bool,
952952
parent_row: usize,
953-
) -> MatrixRow<'a, 'p, Cx> {
953+
) -> MatrixRow<'p, Cx> {
954954
MatrixRow {
955955
pats: self.pats.pop_head_constructor(pcx, ctor, ctor_is_relevant),
956956
parent_row,
@@ -960,7 +960,7 @@ impl<'a, 'p, Cx: TypeCx> MatrixRow<'a, 'p, Cx> {
960960
}
961961
}
962962

963-
impl<'a, 'p, Cx: TypeCx> fmt::Debug for MatrixRow<'a, 'p, Cx> {
963+
impl<'p, Cx: TypeCx> fmt::Debug for MatrixRow<'p, Cx> {
964964
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
965965
self.pats.fmt(f)
966966
}
@@ -977,22 +977,22 @@ impl<'a, 'p, Cx: TypeCx> fmt::Debug for MatrixRow<'a, 'p, Cx> {
977977
/// specializing `(,)` and `Some` on a pattern of type `(Option<u32>, bool)`, the first column of
978978
/// the matrix will correspond to `scrutinee.0.Some.0` and the second column to `scrutinee.1`.
979979
#[derive(Clone)]
980-
struct Matrix<'a, 'p, Cx: TypeCx> {
980+
struct Matrix<'p, Cx: TypeCx> {
981981
/// Vector of rows. The rows must form a rectangular 2D array. Moreover, all the patterns of
982982
/// each column must have the same type. Each column corresponds to a place within the
983983
/// scrutinee.
984-
rows: Vec<MatrixRow<'a, 'p, Cx>>,
984+
rows: Vec<MatrixRow<'p, Cx>>,
985985
/// Stores an extra fictitious row full of wildcards. Mostly used to keep track of the type of
986986
/// each column. This must obey the same invariants as the real rows.
987-
wildcard_row: PatStack<'a, 'p, Cx>,
987+
wildcard_row: PatStack<'p, Cx>,
988988
/// Track for each column/place whether it contains a known valid value.
989989
place_validity: SmallVec<[ValidityConstraint; 2]>,
990990
}
991991

992-
impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
992+
impl<'a, 'p, Cx: TypeCx> Matrix<'p, Cx> {
993993
/// Pushes a new row to the matrix. If the row starts with an or-pattern, this recursively
994994
/// expands it. Internal method, prefer [`Matrix::new`].
995-
fn expand_and_push(&mut self, row: MatrixRow<'a, 'p, Cx>) {
995+
fn expand_and_push(&mut self, row: MatrixRow<'p, Cx>) {
996996
if !row.is_empty() && row.head().is_or_pat() {
997997
// Expand nested or-patterns.
998998
for new_row in row.expand_or_pat() {
@@ -1005,7 +1005,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
10051005

10061006
/// Build a new matrix from an iterator of `MatchArm`s.
10071007
fn new(
1008-
wildcard_arena: &'a TypedArena<DeconstructedPat<'p, Cx>>,
1008+
wildcard_arena: &'p TypedArena<DeconstructedPat<'p, Cx>>,
10091009
arms: &'a [MatchArm<'p, Cx>],
10101010
scrut_ty: Cx::Ty,
10111011
scrut_validity: ValidityConstraint,
@@ -1044,13 +1044,13 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
10441044

10451045
fn rows<'b>(
10461046
&'b self,
1047-
) -> impl Iterator<Item = &'b MatrixRow<'a, 'p, Cx>> + Clone + DoubleEndedIterator + ExactSizeIterator
1047+
) -> impl Iterator<Item = &'b MatrixRow<'p, Cx>> + Clone + DoubleEndedIterator + ExactSizeIterator
10481048
{
10491049
self.rows.iter()
10501050
}
10511051
fn rows_mut<'b>(
10521052
&'b mut self,
1053-
) -> impl Iterator<Item = &'b mut MatrixRow<'a, 'p, Cx>> + DoubleEndedIterator + ExactSizeIterator
1053+
) -> impl Iterator<Item = &'b mut MatrixRow<'p, Cx>> + DoubleEndedIterator + ExactSizeIterator
10541054
{
10551055
self.rows.iter_mut()
10561056
}
@@ -1068,7 +1068,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
10681068
pcx: &PlaceCtxt<'a, 'p, Cx>,
10691069
ctor: &Constructor<Cx>,
10701070
ctor_is_relevant: bool,
1071-
) -> Matrix<'a, 'p, Cx> {
1071+
) -> Matrix<'p, Cx> {
10721072
let wildcard_row = self.wildcard_row.pop_head_constructor(pcx, ctor, ctor_is_relevant);
10731073
let new_validity = self.place_validity[0].specialize(ctor);
10741074
let new_place_validity = std::iter::repeat(new_validity)
@@ -1097,7 +1097,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
10971097
/// + _ + [_, _, tail @ ..] +
10981098
/// | ✓ | ? | // column validity
10991099
/// ```
1100-
impl<'a, 'p, Cx: TypeCx> fmt::Debug for Matrix<'a, 'p, Cx> {
1100+
impl<'p, Cx: TypeCx> fmt::Debug for Matrix<'p, Cx> {
11011101
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11021102
write!(f, "\n")?;
11031103

@@ -1336,7 +1336,7 @@ impl<Cx: TypeCx> WitnessMatrix<Cx> {
13361336
#[instrument(level = "debug", skip(mcx, is_top_level), ret)]
13371337
fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
13381338
mcx: MatchCtxt<'a, 'p, Cx>,
1339-
matrix: &mut Matrix<'a, 'p, Cx>,
1339+
matrix: &mut Matrix<'p, Cx>,
13401340
is_top_level: bool,
13411341
) -> WitnessMatrix<Cx> {
13421342
debug_assert!(matrix.rows().all(|r| r.len() == matrix.column_count()));

0 commit comments

Comments
 (0)