mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 04:18:20 +00:00
allow deref patterns to participate in exhaustiveness analysis Per [this proposal](https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Exhaustiveness), this PR allows deref patterns to participate in exhaustiveness analysis. Currently all deref patterns enforce `DerefPure` bounds on their scrutinees, so this assumes all patterns it's analyzing are well-behaved. This also doesn't support [mixed exhaustiveness](https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Mixed-exhaustiveness), and instead emits an error if deref patterns are used together with normal constructors. I think mixed exhaustiveness would be nice to have (especially if we eventually want to support arbitrary `Deref` impls[^1]), but it'd require more work to get reasonable diagnostics[^2]. Tracking issue for deref patterns: #87121 r? `@Nadrieril` [^1]: Regardless of whether we support limited exhaustiveness checking for untrusted `Deref` or always require other arms to be exhaustive, I think it'd be useful to allow mixed matching for user-defined smart pointers. And it'd be strange if it worked there but not for `Cow`. [^2]: I think listing out witnesses of non-exhaustiveness can be confusing when they're not necessarily disjoint, and when you only need to cover some of them, so we'd probably want special formatting and/or explanatory subdiagnostics. And if it's implemented similarly to unions, we'd probably also want some way of merging witnesses; the way witnesses for unions can appear duplicated is pretty unfortunate. I'm not sure yet how the diagnostics should look, especially for deeply nested patterns. |
||
|---|---|---|
| .. | ||
| base-db | ||
| cfg | ||
| edition | ||
| hir | ||
| hir-def | ||
| hir-expand | ||
| hir-ty | ||
| ide | ||
| ide-assists | ||
| ide-completion | ||
| ide-db | ||
| ide-diagnostics | ||
| ide-ssr | ||
| intern | ||
| load-cargo | ||
| mbe | ||
| parser | ||
| paths | ||
| proc-macro-api | ||
| proc-macro-srv | ||
| proc-macro-srv-cli | ||
| profile | ||
| project-model | ||
| query-group-macro | ||
| rust-analyzer | ||
| span | ||
| stdx | ||
| syntax | ||
| syntax-bridge | ||
| test-fixture | ||
| test-utils | ||
| toolchain | ||
| tt | ||
| vfs | ||
| vfs-notify | ||