about summary refs log tree commit diff
path: root/tests/ui/unsafe
diff options
context:
space:
mode:
authorVeera <sveera.2001@gmail.com>2024-08-06 14:10:00 -0400
committerVeera <sveera.2001@gmail.com>2024-08-06 14:50:09 -0400
commitf003e92a5ba73c673f0faeaac01b6eac6ba3f76a (patch)
tree8c993626ee900780a04d30c5fbd4730adc995b39 /tests/ui/unsafe
parent764675e01aa4f32fd5a84e5f3b6a6e1ca8a1d31e (diff)
downloadrust-f003e92a5ba73c673f0faeaac01b6eac6ba3f76a.tar.gz
rust-f003e92a5ba73c673f0faeaac01b6eac6ba3f76a.zip
Don't Suggest Labeling `const` and `unsafe` Blocks
Diffstat (limited to 'tests/ui/unsafe')
-rw-r--r--tests/ui/unsafe/break-inside-unsafe-block-issue-128604.rs16
-rw-r--r--tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr23
2 files changed, 29 insertions, 10 deletions
diff --git a/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.rs b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.rs
index cbe7a03d389..a83141f0e4e 100644
--- a/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.rs
+++ b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.rs
@@ -15,4 +15,20 @@ fn main() {
         //~^ ERROR `break` outside of a loop or labeled block
     }
 
+    {
+        //~^ HELP consider labeling this block to be able to break within it
+        unsafe {
+            break;
+            //~^ ERROR `break` outside of a loop or labeled block
+        }
+    }
+
+    while 2 > 1 {
+        unsafe {
+            if true || false {
+                break;
+            }
+        }
+    }
+
 }
diff --git a/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr
index 7acfaf403fb..b7cbe1a5cf4 100644
--- a/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr
+++ b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr
@@ -3,11 +3,12 @@ error[E0268]: `break` outside of a loop or labeled block
    |
 LL |     let a = ["_"; unsafe { break; 1 + 2 }];
    |                            ^^^^^ cannot `break` outside of a loop or labeled block
+
+error[E0268]: `break` outside of a loop or labeled block
+  --> $DIR/break-inside-unsafe-block-issue-128604.rs:14:9
    |
-help: consider labeling this block to be able to break within it
-   |
-LL |     let a = ["_"; 'block: unsafe { break 'block; 1 + 2 }];
-   |                   +++++++                ++++++
+LL |         break;
+   |         ^^^^^ cannot `break` outside of a loop or labeled block
 
 error[E0268]: `break` outside of a loop or labeled block
   --> $DIR/break-inside-unsafe-block-issue-128604.rs:8:13
@@ -23,17 +24,19 @@ LL ~             break 'block;
    |
 
 error[E0268]: `break` outside of a loop or labeled block
-  --> $DIR/break-inside-unsafe-block-issue-128604.rs:14:9
+  --> $DIR/break-inside-unsafe-block-issue-128604.rs:21:13
    |
-LL |         break;
-   |         ^^^^^ cannot `break` outside of a loop or labeled block
+LL |             break;
+   |             ^^^^^ cannot `break` outside of a loop or labeled block
    |
 help: consider labeling this block to be able to break within it
    |
-LL ~     'block: unsafe {
-LL ~         break 'block;
+LL ~     'block: {
+LL |
+LL |         unsafe {
+LL ~             break 'block;
    |
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0268`.