summaryrefslogtreecommitdiffstats
path: root/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs')
-rw-r--r--tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs b/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs
new file mode 100644
index 000000000..85b1ef755
--- /dev/null
+++ b/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs
@@ -0,0 +1,21 @@
+#![allow(unused)]
+
+fn test(shouldwe: Option<u32>, shouldwe2: Option<u32>) -> u32 {
+ //~^ NOTE expected `u32` because of return type
+ match shouldwe {
+ Some(val) => {
+ match shouldwe2 {
+ Some(val) => {
+ return val;
+ }
+ None => (), //~ ERROR mismatched types
+ //~^ NOTE expected `u32`, found `()`
+ }
+ }
+ None => return 12,
+ }
+}
+
+fn main() {
+ println!("returned {}", test(None, Some(5)));
+}