diff options
| author | Veera <sveera.2001@gmail.com> | 2024-08-06 14:06:29 -0400 |
|---|---|---|
| committer | Veera <sveera.2001@gmail.com> | 2024-08-06 14:06:29 -0400 |
| commit | 764675e01aa4f32fd5a84e5f3b6a6e1ca8a1d31e (patch) | |
| tree | 6029f660d7e0e260ee9c374c482afa3e722cf6fc /tests/ui/unsafe | |
| parent | 64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b (diff) | |
| download | rust-764675e01aa4f32fd5a84e5f3b6a6e1ca8a1d31e.tar.gz rust-764675e01aa4f32fd5a84e5f3b6a6e1ca8a1d31e.zip | |
Add Tests
Diffstat (limited to 'tests/ui/unsafe')
| -rw-r--r-- | tests/ui/unsafe/break-inside-unsafe-block-issue-128604.rs | 18 | ||||
| -rw-r--r-- | tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr | 39 |
2 files changed, 57 insertions, 0 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 new file mode 100644 index 00000000000..cbe7a03d389 --- /dev/null +++ b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.rs @@ -0,0 +1,18 @@ +fn main() { + let a = ["_"; unsafe { break; 1 + 2 }]; + //~^ ERROR `break` outside of a loop or labeled block + + unsafe { + { + //~^ HELP consider labeling this block to be able to break within it + break; + //~^ ERROR `break` outside of a loop or labeled block + } + } + + unsafe { + break; + //~^ ERROR `break` outside of a loop or labeled block + } + +} diff --git a/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr new file mode 100644 index 00000000000..7acfaf403fb --- /dev/null +++ b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr @@ -0,0 +1,39 @@ +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/break-inside-unsafe-block-issue-128604.rs:2:28 + | +LL | let a = ["_"; unsafe { break; 1 + 2 }]; + | ^^^^^ cannot `break` outside of a loop or labeled block + | +help: consider labeling this block to be able to break within it + | +LL | let a = ["_"; 'block: unsafe { break 'block; 1 + 2 }]; + | +++++++ ++++++ + +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/break-inside-unsafe-block-issue-128604.rs:8:13 + | +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: { +LL | +LL ~ break 'block; + | + +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/break-inside-unsafe-block-issue-128604.rs:14:9 + | +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; + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0268`. |
