summaryrefslogtreecommitdiffstats
path: root/tests/ui/loops
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/loops')
-rw-r--r--tests/ui/loops/issue-50576.rs6
-rw-r--r--tests/ui/loops/issue-50576.stderr22
-rw-r--r--tests/ui/loops/loop-break-value.stderr2
-rw-r--r--tests/ui/loops/loop-else-break-with-value.rs10
-rw-r--r--tests/ui/loops/loop-else-break-with-value.stderr18
-rw-r--r--tests/ui/loops/loop-else-err.rs8
-rw-r--r--tests/ui/loops/loop-else-err.stderr17
-rw-r--r--tests/ui/loops/loop-else-let-else-err.rs8
-rw-r--r--tests/ui/loops/loop-else-let-else-err.stderr17
9 files changed, 107 insertions, 1 deletions
diff --git a/tests/ui/loops/issue-50576.rs b/tests/ui/loops/issue-50576.rs
new file mode 100644
index 000000000..e0c36b827
--- /dev/null
+++ b/tests/ui/loops/issue-50576.rs
@@ -0,0 +1,6 @@
+fn main() {
+ |bool: [u8; break 'L]| 0;
+ //~^ ERROR [E0426]
+ //~| ERROR [E0268]
+ Vec::<[u8; break]>::new(); //~ ERROR [E0268]
+}
diff --git a/tests/ui/loops/issue-50576.stderr b/tests/ui/loops/issue-50576.stderr
new file mode 100644
index 000000000..4ec22fde9
--- /dev/null
+++ b/tests/ui/loops/issue-50576.stderr
@@ -0,0 +1,22 @@
+error[E0426]: use of undeclared label `'L`
+ --> $DIR/issue-50576.rs:2:23
+ |
+LL | |bool: [u8; break 'L]| 0;
+ | ^^ undeclared label `'L`
+
+error[E0268]: `break` outside of a loop or labeled block
+ --> $DIR/issue-50576.rs:2:17
+ |
+LL | |bool: [u8; break 'L]| 0;
+ | ^^^^^^^^ cannot `break` outside of a loop or labeled block
+
+error[E0268]: `break` outside of a loop or labeled block
+ --> $DIR/issue-50576.rs:5:16
+ |
+LL | Vec::<[u8; break]>::new();
+ | ^^^^^ cannot `break` outside of a loop or labeled block
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0268, E0426.
+For more information about an error, try `rustc --explain E0268`.
diff --git a/tests/ui/loops/loop-break-value.stderr b/tests/ui/loops/loop-break-value.stderr
index ccb27c350..5525dbb90 100644
--- a/tests/ui/loops/loop-break-value.stderr
+++ b/tests/ui/loops/loop-break-value.stderr
@@ -167,7 +167,7 @@ error[E0308]: mismatched types
--> $DIR/loop-break-value.rs:80:15
|
LL | break (break, break);
- | ^^^^^^^^^^^^^^ expected `()`, found tuple
+ | ^^^^^^^^^^^^^^ expected `()`, found `(!, !)`
|
= note: expected unit type `()`
found tuple `(!, !)`
diff --git a/tests/ui/loops/loop-else-break-with-value.rs b/tests/ui/loops/loop-else-break-with-value.rs
new file mode 100644
index 000000000..670d8a145
--- /dev/null
+++ b/tests/ui/loops/loop-else-break-with-value.rs
@@ -0,0 +1,10 @@
+fn main() {
+ let Some(1) = loop {
+ //~^ NOTE `else` is attached to this loop
+ break Some(1)
+ } else {
+ //~^ ERROR `loop...else` loops are not supported
+ //~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
+ return;
+ };
+}
diff --git a/tests/ui/loops/loop-else-break-with-value.stderr b/tests/ui/loops/loop-else-break-with-value.stderr
new file mode 100644
index 000000000..972e2d341
--- /dev/null
+++ b/tests/ui/loops/loop-else-break-with-value.stderr
@@ -0,0 +1,18 @@
+error: `loop...else` loops are not supported
+ --> $DIR/loop-else-break-with-value.rs:5:7
+ |
+LL | let Some(1) = loop {
+ | ---- `else` is attached to this loop
+...
+LL | } else {
+ | _______^
+LL | |
+LL | |
+LL | | return;
+LL | | };
+ | |_____^
+ |
+ = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
+
+error: aborting due to previous error
+
diff --git a/tests/ui/loops/loop-else-err.rs b/tests/ui/loops/loop-else-err.rs
new file mode 100644
index 000000000..202a09c25
--- /dev/null
+++ b/tests/ui/loops/loop-else-err.rs
@@ -0,0 +1,8 @@
+fn main() {
+ loop {
+ //~^ NOTE `else` is attached to this loop
+ } else {
+ //~^ ERROR `loop...else` loops are not supported
+ //~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
+ }
+}
diff --git a/tests/ui/loops/loop-else-err.stderr b/tests/ui/loops/loop-else-err.stderr
new file mode 100644
index 000000000..c2c5c84cd
--- /dev/null
+++ b/tests/ui/loops/loop-else-err.stderr
@@ -0,0 +1,17 @@
+error: `loop...else` loops are not supported
+ --> $DIR/loop-else-err.rs:4:7
+ |
+LL | loop {
+ | ---- `else` is attached to this loop
+LL |
+LL | } else {
+ | _______^
+LL | |
+LL | |
+LL | | }
+ | |_____^
+ |
+ = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
+
+error: aborting due to previous error
+
diff --git a/tests/ui/loops/loop-else-let-else-err.rs b/tests/ui/loops/loop-else-let-else-err.rs
new file mode 100644
index 000000000..e828ffef5
--- /dev/null
+++ b/tests/ui/loops/loop-else-let-else-err.rs
@@ -0,0 +1,8 @@
+fn main() {
+ let _ = loop {
+ //~^ NOTE `else` is attached to this loop
+ } else {
+ //~^ ERROR `loop...else` loops are not supported
+ //~| NOTE consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
+ };
+}
diff --git a/tests/ui/loops/loop-else-let-else-err.stderr b/tests/ui/loops/loop-else-let-else-err.stderr
new file mode 100644
index 000000000..a57c784ff
--- /dev/null
+++ b/tests/ui/loops/loop-else-let-else-err.stderr
@@ -0,0 +1,17 @@
+error: `loop...else` loops are not supported
+ --> $DIR/loop-else-let-else-err.rs:4:7
+ |
+LL | let _ = loop {
+ | ---- `else` is attached to this loop
+LL |
+LL | } else {
+ | _______^
+LL | |
+LL | |
+LL | | };
+ | |_____^
+ |
+ = note: consider moving this `else` clause to a separate `if` statement and use a `bool` variable to control if it should run
+
+error: aborting due to previous error
+