summaryrefslogtreecommitdiffstats
path: root/tests/ui/let-else/let-else-non-diverging.stderr
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/let-else/let-else-non-diverging.stderr')
-rw-r--r--tests/ui/let-else/let-else-non-diverging.stderr55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/ui/let-else/let-else-non-diverging.stderr b/tests/ui/let-else/let-else-non-diverging.stderr
new file mode 100644
index 000000000..78551fcc4
--- /dev/null
+++ b/tests/ui/let-else/let-else-non-diverging.stderr
@@ -0,0 +1,55 @@
+error[E0308]: `else` clause of `let...else` does not diverge
+ --> $DIR/let-else-non-diverging.rs:2:32
+ |
+LL | let Some(x) = Some(1) else {
+ | ________________________________^
+LL | | Some(2)
+LL | | };
+ | |_____^ expected `!`, found enum `Option`
+ |
+ = note: expected type `!`
+ found enum `Option<{integer}>`
+ = help: try adding a diverging expression, such as `return` or `panic!(..)`
+ = help: ...or use `match` instead of `let...else`
+
+error[E0308]: `else` clause of `let...else` does not diverge
+ --> $DIR/let-else-non-diverging.rs:5:32
+ |
+LL | let Some(x) = Some(1) else {
+ | ________________________________^
+LL | | if 1 == 1 {
+LL | | panic!();
+LL | | }
+LL | | };
+ | |_____^ expected `!`, found `()`
+ |
+ = note: expected type `!`
+ found unit type `()`
+ = help: try adding a diverging expression, such as `return` or `panic!(..)`
+ = help: ...or use `match` instead of `let...else`
+
+error[E0308]: `else` clause of `let...else` does not diverge
+ --> $DIR/let-else-non-diverging.rs:10:32
+ |
+LL | let Some(x) = Some(1) else { Some(2) };
+ | ^^^^^^^^^^^ expected `!`, found enum `Option`
+ |
+ = note: expected type `!`
+ found enum `Option<{integer}>`
+ = help: try adding a diverging expression, such as `return` or `panic!(..)`
+ = help: ...or use `match` instead of `let...else`
+
+error[E0308]: `else` clause of `let...else` does not diverge
+ --> $DIR/let-else-non-diverging.rs:15:32
+ |
+LL | let Some(x) = Some(1) else { foo::<Uninhabited>() };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `!`, found enum `Uninhabited`
+ |
+ = note: expected type `!`
+ found enum `Uninhabited`
+ = help: try adding a diverging expression, such as `return` or `panic!(..)`
+ = help: ...or use `match` instead of `let...else`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.