diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2023-12-15 16:18:21 +0100 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2023-12-15 16:58:38 +0100 |
| commit | 1e89a38423ee1b562e3b10278d0097d88bc48f5f (patch) | |
| tree | 4f9a1a59238d7c5b80020844b430bab6b6eb4de8 /compiler/rustc_pattern_analysis/src/usefulness.rs | |
| parent | 8c5e89907c1f6312c8613b5d6851381bbcde8052 (diff) | |
| download | rust-1e89a38423ee1b562e3b10278d0097d88bc48f5f.tar.gz rust-1e89a38423ee1b562e3b10278d0097d88bc48f5f.zip | |
`pattern_analysis` doesn't need to know what spans are
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/usefulness.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/usefulness.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_pattern_analysis/src/usefulness.rs b/compiler/rustc_pattern_analysis/src/usefulness.rs index 3141e992f33..88d28c8f483 100644 --- a/compiler/rustc_pattern_analysis/src/usefulness.rs +++ b/compiler/rustc_pattern_analysis/src/usefulness.rs @@ -849,7 +849,7 @@ impl<'a, 'p, Cx: MatchCx> Matrix<'a, 'p, Cx> { scrut_validity: ValidityConstraint, ) -> Self { let wild_pattern = - wildcard_arena.alloc(DeconstructedPat::wildcard(scrut_ty, Cx::Span::default())); + wildcard_arena.alloc(DeconstructedPat::wildcard(scrut_ty, Default::default())); let wildcard_row = PatStack::from_pattern(wild_pattern); let mut matrix = Matrix { rows: Vec::with_capacity(arms.len()), @@ -1287,11 +1287,11 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: MatchCx>( /// Indicates whether or not a given arm is useful. #[derive(Clone, Debug)] -pub enum Usefulness<Span> { +pub enum Usefulness<'p, Cx: MatchCx> { /// The arm is useful. This additionally carries a set of or-pattern branches that have been /// found to be redundant despite the overall arm being useful. Used only in the presence of /// or-patterns, otherwise it stays empty. - Useful(Vec<Span>), + Useful(Vec<&'p DeconstructedPat<'p, Cx>>), /// The arm is redundant and can be removed without changing the behavior of the match /// expression. Redundant, @@ -1300,7 +1300,7 @@ pub enum Usefulness<Span> { /// The output of checking a match for exhaustiveness and arm usefulness. pub struct UsefulnessReport<'p, Cx: MatchCx> { /// For each arm of the input, whether that arm is useful after the arms above it. - pub arm_usefulness: Vec<(MatchArm<'p, Cx>, Usefulness<Cx::Span>)>, + pub arm_usefulness: Vec<(MatchArm<'p, Cx>, Usefulness<'p, Cx>)>, /// If the match is exhaustive, this is empty. If not, this contains witnesses for the lack of /// exhaustiveness. pub non_exhaustiveness_witnesses: Vec<WitnessPat<Cx>>, @@ -1327,7 +1327,7 @@ pub fn compute_match_usefulness<'p, Cx: MatchCx>( debug!(?arm); // We warn when a pattern is not useful. let usefulness = if arm.pat.is_useful() { - Usefulness::Useful(arm.pat.redundant_spans()) + Usefulness::Useful(arm.pat.redundant_subpatterns()) } else { Usefulness::Redundant }; |
