about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2022-12-05 19:42:21 -0800
committerEsteban Küber <esteban@kuber.com.ar>2022-12-27 16:45:55 -0800
commit05e8ba126c7e4918315a35142d73f4e57fb2bb6b (patch)
treea68ecfbbd1fcd9baf706802733d0687f0e4ff13f /src
parent92c1937a90e5b6f20fa6e87016d6869da363972e (diff)
downloadrust-05e8ba126c7e4918315a35142d73f4e57fb2bb6b.tar.gz
rust-05e8ba126c7e4918315a35142d73f4e57fb2bb6b.zip
Account for `match` expr in single line
When encountering `match Some(42) { Some(x) => x, None => "" };`, output

```
error[E0308]: `match` arms have incompatible types
 --> f53.rs:2:52
  |
2 |     let _ = match Some(42) { Some(x) => x, None => "" };
  |             --------------              -          ^^ expected integer, found `&str`
  |             |                           |
  |             |                           this is found to be of type `{integer}`
  |             `match` arms have incompatible types
  ```
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/match/single-line.rs3
-rw-r--r--src/test/ui/match/single-line.stderr12
2 files changed, 15 insertions, 0 deletions
diff --git a/src/test/ui/match/single-line.rs b/src/test/ui/match/single-line.rs
new file mode 100644
index 00000000000..0f69d089f9a
--- /dev/null
+++ b/src/test/ui/match/single-line.rs
@@ -0,0 +1,3 @@
+fn main() {
+    let _ = match Some(42) { Some(x) => x, None => "" }; //~ ERROR E0308
+}
diff --git a/src/test/ui/match/single-line.stderr b/src/test/ui/match/single-line.stderr
new file mode 100644
index 00000000000..ec3b76e3f4d
--- /dev/null
+++ b/src/test/ui/match/single-line.stderr
@@ -0,0 +1,12 @@
+error[E0308]: `match` arms have incompatible types
+  --> $DIR/single-line.rs:2:52
+   |
+LL |     let _ = match Some(42) { Some(x) => x, None => "" };
+   |             --------------              -          ^^ expected integer, found `&str`
+   |             |                           |
+   |             |                           this is found to be of type `{integer}`
+   |             `match` arms have incompatible types
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.