mirror of
https://github.com/rust-lang/rust.git
synced 2025-11-03 06:25:40 +00:00
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.
44 lines
1.5 KiB
Plaintext
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
|
|
|