about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/usefulness.rs
AgeCommit message (Collapse)AuthorLines
2025-07-20List all the variants of non-exhaustive enums in exhaustive modeNadrieril-1/+2
2025-07-20pattern_analysis: add option to get a full set of witnessesNadrieril-1/+3
2025-07-04only check for mixed deref/normal constructors when neededdianne-1/+3
2025-07-04always check for mixed deref pattern and normal constructorsdianne-1/+4
This makes it work for box patterns and in rust-analyzer.
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-2/+2
2025-05-06let deref patterns participate in usefulness/exhaustivenessdianne-1/+3
This does not yet handle the case of mixed deref patterns with normal constructors; it'll ICE in `Constructor::is_covered_by`. That'll be fixed in a later commit.
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-14/+11
2025-02-17Add `pattern_complexity_limit` to `Limits`.Nicholas Nethercote-8/+9
It's similar to the other limits, e.g. obtained via `get_limit`. So it makes sense to handle it consistently with the other limits. We now use `Limit`/`usize` in most places instead of `Option<usize>`, so we use `Limit::new(usize::MAX)`/`usize::MAX` to emulate how `None` used to work. The commit also adds `Limit::unlimited`.
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-7/+7
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-11Revert warning empty patterns as unreachableNadrieril-1/+5
2024-08-10Stabilize `min_exhaustive_patterns`Nadrieril-12/+7
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+8
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-24Explain why a given pattern is considered unreachableNadrieril-48/+145
2024-07-20Expand or-patterns as a separate stepNadrieril-106/+74
2024-05-02Stabilize exclusive_rangeRoss Smyth-1/+0
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-6/+5
2024-04-01Fix union handling in exhaustivenessNadrieril-6/+29
2024-03-31Improve debugging experienceNadrieril-4/+10
2024-03-19Report arm intersectionsNadrieril-4/+21
2024-03-13Rename `TypeCx` -> `PatCx`Nadrieril-37/+37
2024-03-13Rename `ValidityConstraint` -> `PlaceValidity`Nadrieril-18/+10
The old name came from a time where I wanted to reuse it for differentiating wildcards from bindings. I don't plan to do this anymore.
2024-03-11Store field indices in `DeconstructedPat` to avoid virtual wildcardsNadrieril-7/+10
2024-03-09Lint small gaps between rangesNadrieril-4/+42
2024-03-09Make `MaybeInfiniteInt::plus_one/minus_one` fallibleNadrieril-1/+1
2024-03-04Abort on arity mismatchNadrieril-7/+15
As this can cause panics on array accesses later.
2024-03-03Add new `pattern_complexity` attribute to add possibility to limit and check ↵Guillaume Gomez-1/+23
recursion in pattern matching
2024-02-28Rename `Skip` to `PrivateUninhabited`Nadrieril-9/+9
2024-02-28Don't filter out skipped fieldsNadrieril-5/+22
2024-02-28Push the decision to skip fields further downNadrieril-2/+4
2024-02-25Rollup merge of #121324 - Nadrieril:unspecialize, r=cjgillotMatthias Krüger-15/+21
pattern_analysis: factor out unspecialization Just moving a dense bit of logic into its own method.
2024-02-20Auto merge of #120692 - Nadrieril:move-column-analysis-to-placeinfo, ↵bors-74/+90
r=compiler-errors pattern_analysis: Move constructor selection logic to `PlaceInfo` This is a small refactor PR. There was a dense bit of constructor-related logic in `compute_exhaustiveness_and_usefulness`. I'm moving it out into a `PlaceInfo` method to make it easier to follow both separately. I also have plans that will complicate it further so it's good that it's somewhat encapsulated. r? `@compiler-errors`
2024-02-20Factor out unspecializationNadrieril-15/+21
2024-02-12Auto merge of #120324 - Nadrieril:remove-interior-mutability, r=compiler-errorsbors-30/+61
pattern_analysis: track usefulness without interior mutability Because of or-patterns, exhaustiveness needs to be able to lint if a sub-pattern is redundant, e.g. in `Some(_) | Some(true)`. So far the only sane solution I had found was interior mutability. This is a bit of an abstraction leak, and would become a footgun if we ever reused the same `DeconstructedPat`. This PR replaces interior mutability with an address-indexed hashmap, which is logically equivalent.
2024-02-08Move constructor selection logic to `PlaceInfo`Nadrieril-56/+79
2024-02-08Decide which constructors to report earlier.Nadrieril-19/+17
This gets rid of `report_individual_missing_ctors`
2024-02-08Tweak how we record missing constructorsNadrieril-21/+16
This is slower but also not a performance-sensitive path.
2024-02-07Prefer "0..MAX not covered" to "_ not covered"Nadrieril-5/+3
2024-02-07Use a unique id instead of by-address indexingNadrieril-34/+10
2024-02-07Cleanup comments and dead codeNadrieril-9/+5
2024-02-07Track redundant subpatterns without interior mutabilityNadrieril-21/+55
2024-02-07Move usefulness-specific pattern computations to `usefulness`Nadrieril-6/+31
2024-02-07Rollup merge of #120633 - Nadrieril:place_info, r=compiler-errorsGuillaume Boisseau-40/+57
pattern_analysis: gather up place-relevant info We track 3 things about each place during exhaustiveness: its type, its (data) validity, and whether it's the scrutinee place. This PR gathers all three into a single struct. r? `````@compiler-errors`````
2024-02-06Rollup merge of #120331 - Nadrieril:no-arena, r=compiler-errorsMatthias Krüger-2/+2
pattern_analysis: use a plain `Vec` in `DeconstructedPat` The use of an arena-allocated slice in `DeconstructedPat` dates to when we needed the arena anyway for lifetime reasons. Now that we don't, I'm thinking that if `thir::Pat` can use plain old `Vec`s, maybe so can I. r? ```@ghost```
2024-02-06Track `is_top_level` via `PlaceInfo`Nadrieril-10/+14
2024-02-06Zip together `place_ty` and `place_validity`Nadrieril-33/+46
2024-02-05Auto merge of #120313 - Nadrieril:graceful-error, r=compiler-errorsbors-4/+4
pattern_analysis: Gracefully abort on type incompatibility This leaves the option for a consumer of the crate to return `Err` instead of panicking on type error. rust-analyzer could use that (e.g. https://github.com/rust-lang/rust-analyzer/issues/15808). Since the only use of `TypeCx::bug` is in `Constructor::is_covered_by`, it is tempting to return `false` instead of `Err()`, but that would cause "non-exhaustive match" false positives. r? `@compiler-errors`
2024-02-03Rollup merge of #120516 - Nadrieril:cleanup-impls, r=compiler-errorsMatthias Krüger-12/+2
pattern_analysis: cleanup manual impls https://github.com/rust-lang/rust/pull/120420 introduced some unneeded manual impls. I remove them here. r? ```@Nilstrieb```
2024-01-31Use a `Vec` instead of a slice in `DeconstructedPat`Nadrieril-2/+2
2024-01-31Gracefully abort on type incompatibilityNadrieril-4/+4
Since the only use of `TypeCx::bug` is in `Constructor::is_covered_by`, it is tempting to return `false` instead of `Err()`, but that would cause "non-exhaustive match" false positives.