Commit Graph

52 Commits

Author SHA1 Message Date
Marijn Schouten 5d8a096afe change non-canonical clone impl to {*self}, fix some doc comments 2025-12-20 13:46:22 +00:00
Michael Goulet c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Nadrieril 64ac2b8082 Explain why a given pattern is considered unreachable 2024-07-24 08:02:55 +02:00
Nadrieril 670723e6fb Expand or-patterns as a separate step 2024-07-20 22:28:54 +02:00
Nicholas Nethercote 665821cb60 Add blank lines after module-level //! comments.
Most modules have such a blank line, but some don't. Inserting the blank
line makes it clearer that the `//!` comments are describing the entire
module, rather than the `use` declaration(s) that immediately follows.
2024-06-20 09:23:20 +10:00
Nadrieril e4487ad391 Improve the WitnessPat: Debug impl 2024-03-19 02:22:43 +01:00
Matthias Krüger 2d3dcfaade Rollup merge of #121823 - Nadrieril:never-witnesses, r=compiler-errors
never patterns: suggest `!` patterns on non-exhaustive matches

When a match is non-exhaustive we now suggest never patterns whenever it makes sense.

r? ``@compiler-errors``
2024-03-18 22:24:36 +01:00
Nadrieril 4fc35c46ff Rename TypeCx -> PatCx 2024-03-13 13:56:38 +01:00
Nadrieril b878ab6a27 Don't suggest an arm when suggesting a never pattern 2024-03-12 21:38:31 +01:00
Nadrieril 9f2aa5b85a Suggest never pattern instead of _ for empty types 2024-03-12 21:38:30 +01:00
Nadrieril 1ec73d70fa Add Constructor::Never 2024-03-12 21:38:30 +01:00
Nadrieril d339bdaa07 DeconstructedPat.data is always present now 2024-03-11 04:38:57 +01:00
Nadrieril 6ae9fa31f0 Store field indices in DeconstructedPat to avoid virtual wildcards 2024-03-11 04:37:21 +01:00
Nadrieril c1e68860d0 Store pattern arity in DeconstructedPat
Right now this is just `self.fields.len()` but that'll change in the
next commit. `arity` will be useful for the `Debug` impl.
2024-03-11 04:37:21 +01:00
Nadrieril c918893b63 Rename Skip to PrivateUninhabited 2024-02-28 17:56:01 +01:00
Nadrieril ea38166390 Don't filter out skipped fields 2024-02-28 17:47:19 +01:00
Nadrieril 4f7f06777b Add special Skip constructor 2024-02-28 17:47:19 +01:00
Nadrieril ab06037269 Push the decision to skip fields further down 2024-02-28 17:47:19 +01:00
Nadrieril be29cd173a Use a unique id instead of by-address indexing 2024-02-07 23:16:47 +01:00
Nadrieril 8465c82b64 Cleanup comments and dead code 2024-02-07 23:16:47 +01:00
Nadrieril cb3ce6645f Move usefulness-specific pattern computations to usefulness 2024-02-07 23:10:51 +01:00
Matthias Krüger ce32d4862b Rollup merge of #120331 - Nadrieril:no-arena, r=compiler-errors
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-06 22:45:40 +01:00
Matthias Krüger f3ebf1e50f Rollup merge of #120516 - Nadrieril:cleanup-impls, r=compiler-errors
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-02-03 22:25:14 +01:00
Nadrieril be77cf86ba Use a Vec instead of a slice in DeconstructedPat 2024-01-31 19:25:40 +01:00
Nadrieril 40402cbada Manual Debug impls are not needed since TypeCx: Debug 2024-01-31 01:32:05 +01:00
Nadrieril cb0e8c508c Limit the use of PlaceCtxt 2024-01-30 17:06:30 +01:00
Laurențiu Nicola f5c78955c8 Stop using derivative in rustc_pattern_analysis 2024-01-27 14:21:01 +02:00
Matthias Krüger a1ecced532 Rollup merge of #120318 - Nadrieril:share-debug-impl, r=compiler-errors
pattern_analysis: Reuse most of the `DeconstructedPat` `Debug` impl

The `DeconstructedPat: Debug` is best-effort because we'd need `tcx` to get things like field names etc. Since rust-analyzer has a similar constraint, this PR moves most the impl to be shared between the two. While I was at it I also fixed a nit in the `IntRange: Debug` impl.

r? `@compiler-errors`
2024-01-25 08:39:45 +01:00
Nadrieril bdab213993 Most of the DeconstructedPat Debug impl is reusable 2024-01-24 20:04:33 +01:00
Nadrieril e088016f9d Let ctor_sub_tys return any Iterator they want
Since we always clone and allocate the types somewhere else ourselves,
no need to ask for `Cx` to do the allocation.
2024-01-24 16:55:26 +01:00
Nadrieril 796cdc590c Remove Ty: Copy bound 2024-01-20 15:22:14 +01:00
Nadrieril db36304102 rustc_pattern_analysis no longer needs to be passed an arena 2024-01-12 18:55:27 +01:00
Nadrieril 5c65e9fdaf Avoid PatOrWild glob import 2024-01-09 16:22:11 +01:00
Nadrieril 1a3edc169b We only need the arity of the subtype list now 2024-01-07 19:20:19 +01:00
Nadrieril 4ae2840e84 Use special enum to represent algorithm-generated wildcards in the matrix 2024-01-07 19:20:19 +01:00
Nadrieril 50b197c6ee Reuse ctor_sub_tys when we have one around 2024-01-06 18:03:13 +01:00
Michael Goulet ae40f6a7ff Clean up more lifetimes 2023-12-26 02:06:39 +00:00
Michael Goulet eebb2abe0b Yeet some lifetimes 2023-12-26 01:59:18 +00:00
Nadrieril 5fccaee59c Clarify the situation with dummy patterns and PatData
Use an explicit `Option` instead of requiring a `Default` bound
2023-12-23 00:08:38 +01:00
Nadrieril c6aa16c469 Use derivative for better derive bounds 2023-12-23 00:04:20 +01:00
Nadrieril 3016c29628 s/MatchCx/TypeCx/ 2023-12-15 17:26:19 +01:00
Nadrieril 4bcf66f875 Introduce MatchCtxt 2023-12-15 16:58:38 +01:00
Nadrieril 60ea14bfaa s/PatCtxt/PlaceCtxt/ 2023-12-15 16:58:38 +01:00
Nadrieril 1e89a38423 pattern_analysis doesn't need to know what spans are 2023-12-15 16:58:38 +01:00
Nadrieril e646c9f723 Make the rustc_data_structures dependency optional 2023-12-15 16:58:38 +01:00
Nadrieril 3d7c4df326 Abstract MatchCheckCtxt into a trait 2023-12-15 16:58:36 +01:00
Nadrieril 3ad76f9325 Disentangle the arena from MatchCheckCtxt 2023-12-15 16:57:36 +01:00
Nadrieril 081c3dcf43 Remove all matching on ty.kind() outside cx 2023-12-15 16:57:36 +01:00
Nadrieril 5d6c539c2d Fix item visibilities 2023-12-11 11:20:55 +01:00