about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src
AgeCommit message (Collapse)AuthorLines
2023-12-24Auto merge of #118796 - Nadrieril:fix-exponential-id-match-2, r=cjgillotbors-29/+205
Exhaustiveness: Improve complexity on some wide matches https://github.com/rust-lang/rust/issues/118437 revealed an exponential case in exhaustiveness checking. While [exponential cases are unavoidable](https://compilercrim.es/rust-np/), this one only showed up after my https://github.com/rust-lang/rust/pull/117611 rewrite of the algorithm. I remember anticipating a case like this and dismissing it as unrealistic, but here we are :'). The tricky match is as follows: ```rust match command { BaseCommand { field01: true, .. } => {} BaseCommand { field02: true, .. } => {} BaseCommand { field03: true, .. } => {} BaseCommand { field04: true, .. } => {} BaseCommand { field05: true, .. } => {} BaseCommand { field06: true, .. } => {} BaseCommand { field07: true, .. } => {} BaseCommand { field08: true, .. } => {} BaseCommand { field09: true, .. } => {} BaseCommand { field10: true, .. } => {} // ...20 more of the same _ => {} } ``` To fix this, this PR formalizes a concept of "relevancy" (naming is hard) that was already used to decide what patterns to report. Now we track it for every row, which in wide matches like the above can drastically cut on the number of cases we explore. After this fix, the above match is checked with linear-many cases instead of exponentially-many. Fixes https://github.com/rust-lang/rust/issues/118437 r? `@cjgillot`
2023-12-23Rework the explanation of relevancyNadrieril-48/+138
2023-12-23Reveal empty opaques in depthNadrieril-4/+14
2023-12-23Improve performance on wide matchesNadrieril-29/+115
2023-12-23Clarify the situation with dummy patterns and `PatData`Nadrieril-17/+19
Use an explicit `Option` instead of requiring a `Default` bound
2023-12-23Use `derivative` for better derive boundsNadrieril-21/+19
2023-12-20Reveal opaque types in exhaustiveness checkingNadrieril-33/+33
2023-12-19Auto merge of #118842 - Nadrieril:librarify-further, r=compiler-errorsbors-419/+606
Make exhaustiveness usable outside of rustc With this PR, `rustc_pattern_analysis` compiles on stable (with the `stable` feature)! `rust-analyzer` will be able to use it to provide match-related diagnostics and refactors. Two questions: - Should I name the feature `nightly` instead of `rustc` for consistency with other crates? `rustc` makes more sense imo. - `typed-arena` is an optional dependency but tidy made me add it to the allow-list anyway. Can I avoid that somehow? r? `@compiler-errors`
2023-12-15NFC: do not clone types that are copyMatthias Krüger-1/+1
2023-12-15s/MatchCx/TypeCx/Nadrieril-48/+48
2023-12-15Introduce `MatchCtxt`Nadrieril-77/+93
2023-12-15s/PatCtxt/PlaceCtxt/Nadrieril-33/+33
2023-12-15`pattern_analysis` doesn't need to know what spans areNadrieril-28/+31
2023-12-15Address review commentsNadrieril-12/+4
2023-12-15s/RustcCtxt/RustcMatchCheckCtxt/Nadrieril-34/+44
2023-12-15Make the crate compile on stableNadrieril-0/+5
2023-12-15Make the `rustc_data_structures` dependency optionalNadrieril-12/+26
2023-12-15Gate rustc-specific code under a featureNadrieril-8/+20
2023-12-15Iron out last rustc-specific detailsNadrieril-14/+38
2023-12-15Name rustc-specific things "rustc"Nadrieril-43/+36
2023-12-15Abstract `MatchCheckCtxt` into a traitNadrieril-218/+294
2023-12-15Disentangle the arena from `MatchCheckCtxt`Nadrieril-116/+135
2023-12-15Remove all matching on `ty.kind()` outside `cx`Nadrieril-36/+31
2023-12-15Split `Single` ctor into more specific variantsNadrieril-51/+79
2023-12-12Update compiler/rustc_pattern_analysis/src/constructor.rs Matthias Krüger-0/+1
add note that `missing_empty` is cleared now Co-authored-by: Nadrieril <Nadrieril@users.noreply.github.com>
2023-12-12simplify merging of two vecsMatthias Krüger-1/+1
2023-12-11Fix doc linksNadrieril-22/+22
2023-12-11Fix item visibilitiesNadrieril-31/+27
2023-12-11Make `MaybeInfiniteInt` rustc-independentNadrieril-34/+59
2023-12-11Move lints to their own moduleNadrieril-297/+343
2023-12-11Gather rustc-specific functions around `MatchCheckCtxt`Nadrieril-889/+891
2023-12-11Extract exhaustiveness into its own crateNadrieril-0/+3739