about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-06-19 16:27:26 -0700
committerMichael Goulet <michael@errs.io>2022-06-19 16:46:37 -0700
commit2c3bb42ebd86247ea5d2fb4daa51d9ada3f6ae61 (patch)
tree9cee79194922acbf2b77025795c54da52418a549 /src
parent2b646bd533e8a20c06a71d0b7837e15eb4c79fa8 (diff)
downloadrust-2c3bb42ebd86247ea5d2fb4daa51d9ada3f6ae61.tar.gz
rust-2c3bb42ebd86247ea5d2fb4daa51d9ada3f6ae61.zip
Only omit trailing comma if block doesn't come from macro expansion
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/issue-94866.rs14
-rw-r--r--src/test/ui/issue-94866.stderr21
-rw-r--r--src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr2
3 files changed, 36 insertions, 1 deletions
diff --git a/src/test/ui/issue-94866.rs b/src/test/ui/issue-94866.rs
new file mode 100644
index 00000000000..c4203487936
--- /dev/null
+++ b/src/test/ui/issue-94866.rs
@@ -0,0 +1,14 @@
+macro_rules! m {
+    () => {
+        {}
+    };
+}
+
+enum Enum { A, B }
+
+fn main() {
+    match Enum::A {
+    //~^ ERROR non-exhaustive patterns
+    Enum::A => m!()
+    }
+}
diff --git a/src/test/ui/issue-94866.stderr b/src/test/ui/issue-94866.stderr
new file mode 100644
index 00000000000..5477d83f449
--- /dev/null
+++ b/src/test/ui/issue-94866.stderr
@@ -0,0 +1,21 @@
+error[E0004]: non-exhaustive patterns: `B` not covered
+  --> $DIR/issue-94866.rs:10:11
+   |
+LL |     match Enum::A {
+   |           ^^^^^^^ pattern `B` not covered
+   |
+note: `Enum` defined here
+  --> $DIR/issue-94866.rs:7:16
+   |
+LL | enum Enum { A, B }
+   |      ----      ^ not covered
+   = note: the matched value is of type `Enum`
+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 ~     Enum::A => m!(),
+LL +     B => todo!()
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0004`.
diff --git a/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr b/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
index fc0430d06fa..e2a65ff8524 100644
--- a/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
+++ b/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr
@@ -12,7 +12,7 @@ LL | struct Foo(isize, isize);
    = note: the matched value is of type `Foo`
 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 ~         Foo(2, b) => println!("{}", b)
+LL ~         Foo(2, b) => println!("{}", b),
 LL +         Foo(_, _) => todo!()
    |