Skip to content

Commit 128f2b5

Browse files
committed
Test that label break value only works on actual blocks
1 parent f8c2598 commit 128f2b5

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// These are forbidden occurences of label-break-value
12+
13+
fn labeled_unsafe() {
14+
unsafe 'b: {} //~ ERROR expected one of `extern`, `fn`, or `{`
15+
}
16+
17+
fn labeled_if() {
18+
if true 'b: {} //~ ERROR expected `{`, found `'b`
19+
}
20+
21+
fn labeled_else() {
22+
if true {} else 'b: {} //~ ERROR expected `{`, found `'b`
23+
}
24+
25+
fn labeled_match() {
26+
match false 'b: {} //~ ERROR expected one of `.`, `?`, `{`, or an operator
27+
}
28+
29+
pub fn main() {}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error: expected one of `extern`, `fn`, or `{`, found `'b`
2+
--> $DIR/label_break_value_illegal_uses.rs:14:12
3+
|
4+
LL | unsafe 'b: {} //~ ERROR expected one of `extern`, `fn`, or `{`
5+
| ^^ expected one of `extern`, `fn`, or `{` here
6+
7+
error: expected `{`, found `'b`
8+
--> $DIR/label_break_value_illegal_uses.rs:18:13
9+
|
10+
LL | if true 'b: {} //~ ERROR expected `{`, found `'b`
11+
| -- ^^----
12+
| | |
13+
| | help: try placing this code inside a block: `{ 'b: { } }`
14+
| this `if` statement has a condition, but no block
15+
16+
error: expected `{`, found `'b`
17+
--> $DIR/label_break_value_illegal_uses.rs:22:21
18+
|
19+
LL | if true {} else 'b: {} //~ ERROR expected `{`, found `'b`
20+
| ^^----
21+
| |
22+
| help: try placing this code inside a block: `{ 'b: { } }`
23+
24+
error: expected one of `.`, `?`, `{`, or an operator, found `'b`
25+
--> $DIR/label_break_value_illegal_uses.rs:26:17
26+
|
27+
LL | match false 'b: {} //~ ERROR expected one of `.`, `?`, `{`, or an operator
28+
| ^^ expected one of `.`, `?`, `{`, or an operator here
29+
30+
error: aborting due to 4 previous errors
31+

0 commit comments

Comments
 (0)