mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
show a trailing comma on singleton tuple constructors in witness pats
This commit is contained in:
@@ -119,6 +119,9 @@ pub(crate) fn write_struct_like<'tcx>(
|
||||
write!(f, "_")?;
|
||||
}
|
||||
}
|
||||
if matches!(ty.kind(), ty::Tuple(..)) && num_fields == 1 {
|
||||
write!(f, ",")?;
|
||||
}
|
||||
write!(f, ")")?;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ fn main() {
|
||||
(0 | 1, 2 | 3) => {}
|
||||
}
|
||||
match ((0u8,),) {
|
||||
//~^ ERROR non-exhaustive patterns: `((4_u8..=u8::MAX))`
|
||||
//~^ ERROR non-exhaustive patterns: `((4_u8..=u8::MAX,),)`
|
||||
((0 | 1,) | (2 | 3,),) => {}
|
||||
}
|
||||
match (Some(0u8),) {
|
||||
//~^ ERROR non-exhaustive patterns: `(Some(2_u8..=u8::MAX))`
|
||||
//~^ ERROR non-exhaustive patterns: `(Some(2_u8..=u8::MAX),)`
|
||||
(None | Some(0 | 1),) => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,30 +11,30 @@ LL ~ (0 | 1, 2 | 3) => {},
|
||||
LL + (2_u8..=u8::MAX, _) => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `((4_u8..=u8::MAX))` not covered
|
||||
error[E0004]: non-exhaustive patterns: `((4_u8..=u8::MAX,),)` not covered
|
||||
--> $DIR/exhaustiveness-non-exhaustive.rs:9:11
|
||||
|
|
||||
LL | match ((0u8,),) {
|
||||
| ^^^^^^^^^ pattern `((4_u8..=u8::MAX))` not covered
|
||||
| ^^^^^^^^^ pattern `((4_u8..=u8::MAX,),)` not covered
|
||||
|
|
||||
= note: the matched value is of type `((u8,),)`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
||||
|
|
||||
LL ~ ((0 | 1,) | (2 | 3,),) => {},
|
||||
LL + ((4_u8..=u8::MAX)) => todo!()
|
||||
LL + ((4_u8..=u8::MAX,),) => todo!()
|
||||
|
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `(Some(2_u8..=u8::MAX))` not covered
|
||||
error[E0004]: non-exhaustive patterns: `(Some(2_u8..=u8::MAX),)` not covered
|
||||
--> $DIR/exhaustiveness-non-exhaustive.rs:13:11
|
||||
|
|
||||
LL | match (Some(0u8),) {
|
||||
| ^^^^^^^^^^^^ pattern `(Some(2_u8..=u8::MAX))` not covered
|
||||
| ^^^^^^^^^^^^ pattern `(Some(2_u8..=u8::MAX),)` not covered
|
||||
|
|
||||
= note: the matched value is of type `(Option<u8>,)`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
||||
|
|
||||
LL ~ (None | Some(0 | 1),) => {},
|
||||
LL + (Some(2_u8..=u8::MAX)) => todo!()
|
||||
LL + (Some(2_u8..=u8::MAX),) => todo!()
|
||||
|
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Reference in New Issue
Block a user