summaryrefslogtreecommitdiffstats
path: root/tests/ui/let-else
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
commit3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 (patch)
treedaf049b282ab10e8c3d03e409b3cd84ff3f7690c /tests/ui/let-else
parentAdding debian version 1.68.2+dfsg1-1. (diff)
downloadrustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.tar.xz
rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/let-else')
-rw-r--r--tests/ui/let-else/accidental-if.rs6
-rw-r--r--tests/ui/let-else/accidental-if.stderr19
-rw-r--r--tests/ui/let-else/issue-94176.stderr2
-rw-r--r--tests/ui/let-else/let-else-brace-before-else.fixed4
-rw-r--r--tests/ui/let-else/let-else-brace-before-else.rs4
-rw-r--r--tests/ui/let-else/let-else-brace-before-else.stderr17
-rw-r--r--tests/ui/let-else/let-else-deref-coercion.stderr4
-rw-r--r--tests/ui/let-else/let-else-non-diverging.stderr6
-rw-r--r--tests/ui/let-else/let-else-ref-bindings.stderr16
9 files changed, 42 insertions, 36 deletions
diff --git a/tests/ui/let-else/accidental-if.rs b/tests/ui/let-else/accidental-if.rs
new file mode 100644
index 000000000..3fba63043
--- /dev/null
+++ b/tests/ui/let-else/accidental-if.rs
@@ -0,0 +1,6 @@
+fn main() {
+ let x = Some(123);
+ if let Some(y) = x else { //~ ERROR this `if` expression is missing a block
+ return;
+ };
+}
diff --git a/tests/ui/let-else/accidental-if.stderr b/tests/ui/let-else/accidental-if.stderr
new file mode 100644
index 000000000..57e525917
--- /dev/null
+++ b/tests/ui/let-else/accidental-if.stderr
@@ -0,0 +1,19 @@
+error: this `if` expression is missing a block after the condition
+ --> $DIR/accidental-if.rs:3:5
+ |
+LL | if let Some(y) = x else {
+ | ^^
+ |
+help: add a block here
+ --> $DIR/accidental-if.rs:3:23
+ |
+LL | if let Some(y) = x else {
+ | ^
+help: remove the `if` if you meant to write a `let...else` statement
+ |
+LL - if let Some(y) = x else {
+LL + let Some(y) = x else {
+ |
+
+error: aborting due to previous error
+
diff --git a/tests/ui/let-else/issue-94176.stderr b/tests/ui/let-else/issue-94176.stderr
index 0cb97acee..6a015aced 100644
--- a/tests/ui/let-else/issue-94176.stderr
+++ b/tests/ui/let-else/issue-94176.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-94176.rs:5:32
|
LL | pub fn test(a: Option<u32>) -> Option<u32> {
- | ---- ^^^^^^^^^^^ expected enum `Option`, found `()`
+ | ---- ^^^^^^^^^^^ expected `Option<u32>`, found `()`
| |
| implicitly returns `()` as its body has no tail or `return` expression
|
diff --git a/tests/ui/let-else/let-else-brace-before-else.fixed b/tests/ui/let-else/let-else-brace-before-else.fixed
index a75c770dd..2d85e3878 100644
--- a/tests/ui/let-else/let-else-brace-before-else.fixed
+++ b/tests/ui/let-else/let-else-brace-before-else.fixed
@@ -7,10 +7,6 @@ fn main() {
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
return;
};
- let Some(1) = (loop { break Some(1) }) else {
- //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
- return;
- };
let 2 = 1 + (match 1 { n => n }) else {
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
return;
diff --git a/tests/ui/let-else/let-else-brace-before-else.rs b/tests/ui/let-else/let-else-brace-before-else.rs
index 5603b946f..5c3375b3f 100644
--- a/tests/ui/let-else/let-else-brace-before-else.rs
+++ b/tests/ui/let-else/let-else-brace-before-else.rs
@@ -7,10 +7,6 @@ fn main() {
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
return;
};
- let Some(1) = loop { break Some(1) } else {
- //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
- return;
- };
let 2 = 1 + match 1 { n => n } else {
//~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
return;
diff --git a/tests/ui/let-else/let-else-brace-before-else.stderr b/tests/ui/let-else/let-else-brace-before-else.stderr
index cb01e4c18..ee53213d8 100644
--- a/tests/ui/let-else/let-else-brace-before-else.stderr
+++ b/tests/ui/let-else/let-else-brace-before-else.stderr
@@ -10,18 +10,7 @@ LL | let Some(1) = ({ Some(1) }) else {
| + +
error: right curly brace `}` before `else` in a `let...else` statement not allowed
- --> $DIR/let-else-brace-before-else.rs:10:40
- |
-LL | let Some(1) = loop { break Some(1) } else {
- | ^
- |
-help: wrap the expression in parentheses
- |
-LL | let Some(1) = (loop { break Some(1) }) else {
- | + +
-
-error: right curly brace `}` before `else` in a `let...else` statement not allowed
- --> $DIR/let-else-brace-before-else.rs:14:34
+ --> $DIR/let-else-brace-before-else.rs:10:34
|
LL | let 2 = 1 + match 1 { n => n } else {
| ^
@@ -32,7 +21,7 @@ LL | let 2 = 1 + (match 1 { n => n }) else {
| + +
error: right curly brace `}` before `else` in a `let...else` statement not allowed
- --> $DIR/let-else-brace-before-else.rs:18:40
+ --> $DIR/let-else-brace-before-else.rs:14:40
|
LL | let Some(1) = unsafe { unsafe_fn() } else {
| ^
@@ -42,5 +31,5 @@ help: wrap the expression in parentheses
LL | let Some(1) = (unsafe { unsafe_fn() }) else {
| + +
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
diff --git a/tests/ui/let-else/let-else-deref-coercion.stderr b/tests/ui/let-else/let-else-deref-coercion.stderr
index bf78a079c..143b838ba 100644
--- a/tests/ui/let-else/let-else-deref-coercion.stderr
+++ b/tests/ui/let-else/let-else-deref-coercion.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | let Bar::Present(z) = self else {
| ^^^^^^^^^^^^^^^ ---- this expression has type `&mut Foo`
| |
- | expected struct `Foo`, found enum `Bar`
+ | expected `Foo`, found `Bar`
error[E0308]: mismatched types
--> $DIR/let-else-deref-coercion.rs:68:13
@@ -12,7 +12,7 @@ error[E0308]: mismatched types
LL | let Bar(z) = x;
| ^^^^^^ - this expression has type `&mut irrefutable::Foo`
| |
- | expected struct `Foo`, found struct `Bar`
+ | expected `Foo`, found `Bar`
error: aborting due to 2 previous errors
diff --git a/tests/ui/let-else/let-else-non-diverging.stderr b/tests/ui/let-else/let-else-non-diverging.stderr
index 78551fcc4..661d905cd 100644
--- a/tests/ui/let-else/let-else-non-diverging.stderr
+++ b/tests/ui/let-else/let-else-non-diverging.stderr
@@ -5,7 +5,7 @@ LL | let Some(x) = Some(1) else {
| ________________________________^
LL | | Some(2)
LL | | };
- | |_____^ expected `!`, found enum `Option`
+ | |_____^ expected `!`, found `Option<{integer}>`
|
= note: expected type `!`
found enum `Option<{integer}>`
@@ -32,7 +32,7 @@ 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`
+ | ^^^^^^^^^^^ expected `!`, found `Option<{integer}>`
|
= note: expected type `!`
found enum `Option<{integer}>`
@@ -43,7 +43,7 @@ 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`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `!`, found `Uninhabited`
|
= note: expected type `!`
found enum `Uninhabited`
diff --git a/tests/ui/let-else/let-else-ref-bindings.stderr b/tests/ui/let-else/let-else-ref-bindings.stderr
index 56b9e0733..ada1805e7 100644
--- a/tests/ui/let-else/let-else-ref-bindings.stderr
+++ b/tests/ui/let-else/let-else-ref-bindings.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:16:38
|
LL | let Some(ref a): Option<&[u8]> = some else { return };
- | ^^^^ expected `&[u8]`, found struct `Vec`
+ | ^^^^ expected `Option<&[u8]>`, found `Option<Vec<u8>>`
|
= note: expected enum `Option<&[u8]>`
found enum `Option<Vec<u8>>`
@@ -11,7 +11,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:20:38
|
LL | let Some(ref a): Option<&[u8]> = &some else { return };
- | ^^^^^ expected enum `Option`, found `&Option<Vec<u8>>`
+ | ^^^^^ expected `Option<&[u8]>`, found `&Option<Vec<u8>>`
|
= note: expected enum `Option<&[u8]>`
found reference `&Option<Vec<u8>>`
@@ -20,7 +20,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:24:34
|
LL | let Some(a): Option<&[u8]> = some else { return };
- | ------------- ^^^^ expected `&[u8]`, found struct `Vec`
+ | ------------- ^^^^ expected `Option<&[u8]>`, found `Option<Vec<u8>>`
| |
| expected due to this
|
@@ -31,7 +31,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:27:34
|
LL | let Some(a): Option<&[u8]> = &some else { return };
- | ------------- ^^^^^ expected enum `Option`, found `&Option<Vec<u8>>`
+ | ------------- ^^^^^ expected `Option<&[u8]>`, found `&Option<Vec<u8>>`
| |
| expected due to this
|
@@ -42,7 +42,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:44:46
|
LL | let Some(ref mut a): Option<&mut [u8]> = some else { return };
- | ^^^^ expected `&mut [u8]`, found struct `Vec`
+ | ^^^^ expected `Option<&mut [u8]>`, found `Option<Vec<u8>>`
|
= note: expected enum `Option<&mut [u8]>`
found enum `Option<Vec<u8>>`
@@ -51,7 +51,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:48:46
|
LL | let Some(ref mut a): Option<&mut [u8]> = &mut some else { return };
- | ^^^^^^^^^ expected enum `Option`, found mutable reference
+ | ^^^^^^^^^ expected `Option<&mut [u8]>`, found `&mut Option<Vec<u8>>`
|
= note: expected enum `Option<&mut [u8]>`
found mutable reference `&mut Option<Vec<u8>>`
@@ -60,7 +60,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:52:38
|
LL | let Some(a): Option<&mut [u8]> = some else { return };
- | ----------------- ^^^^ expected `&mut [u8]`, found struct `Vec`
+ | ----------------- ^^^^ expected `Option<&mut [u8]>`, found `Option<Vec<u8>>`
| |
| expected due to this
|
@@ -71,7 +71,7 @@ error[E0308]: mismatched types
--> $DIR/let-else-ref-bindings.rs:55:38
|
LL | let Some(a): Option<&mut [u8]> = &mut some else { return };
- | ----------------- ^^^^^^^^^ expected enum `Option`, found mutable reference
+ | ----------------- ^^^^^^^^^ expected `Option<&mut [u8]>`, found `&mut Option<Vec<u8>>`
| |
| expected due to this
|