rust/tests/ui/pattern/deref-patterns/usefulness/mixed-constructors.stderr
dianne fb261a179d error early when mixing deref patterns with normal constructors
Without adding proper support for mixed exhaustiveness, mixing deref
patterns with normal constructors would either violate
`ConstructorSet::split`'s invariant 4 or 7. We'd either be ignoring rows
with normal constructors or we'd have problems in unspecialization from
non-disjoint constructors. Checking mixed exhaustivenss similarly to how
unions are currently checked should work, but the diagnostics for unions
are confusing. Since mixing deref patterns with normal constructors is
pretty niche (currently it only makes sense for `Cow`), emitting an
error lets us avoid committing to supporting mixed exhaustiveness
without a good answer for the diagnostics.
2025-05-06 18:53:55 -07:00

44 lines
1.5 KiB
Plaintext

error: mix of deref patterns and normal constructors
--> $DIR/mixed-constructors.rs:16:9
|
LL | false => {}
| ^^^^^ matches on the result of dereferencing `Cow<'_, bool>`
LL | Cow::Borrowed(_) => {}
| ^^^^^^^^^^^^^^^^ matches directly on `Cow<'_, bool>`
error: mix of deref patterns and normal constructors
--> $DIR/mixed-constructors.rs:22:9
|
LL | Cow::Borrowed(_) => {}
| ^^^^^^^^^^^^^^^^ matches directly on `Cow<'_, bool>`
LL | true => {}
| ^^^^ matches on the result of dereferencing `Cow<'_, bool>`
error: mix of deref patterns and normal constructors
--> $DIR/mixed-constructors.rs:29:9
|
LL | Cow::Owned(_) => {}
| ^^^^^^^^^^^^^ matches directly on `Cow<'_, bool>`
LL | false => {}
| ^^^^^ matches on the result of dereferencing `Cow<'_, bool>`
error: mix of deref patterns and normal constructors
--> $DIR/mixed-constructors.rs:36:10
|
LL | (Cow::Borrowed(_), 0) => {}
| ^^^^^^^^^^^^^^^^ matches directly on `Cow<'_, bool>`
LL | (true, 0) => {}
| ^^^^ matches on the result of dereferencing `Cow<'_, bool>`
error: mix of deref patterns and normal constructors
--> $DIR/mixed-constructors.rs:43:13
|
LL | (0, Cow::Borrowed(_)) => {}
| ^^^^^^^^^^^^^^^^ matches directly on `Cow<'_, bool>`
LL | _ => {}
LL | (1, true) => {}
| ^^^^ matches on the result of dereferencing `Cow<'_, bool>`
error: aborting due to 5 previous errors