Rollup merge of #50793 - jrlusby:master, r=petrochenkov
tidy: Add a check for empty UI test files Check for empty `.stderr` and `.stdout` files in UI test directories. Empty files could still pass testing for `compile-pass` tests with no output so they can get into the repo accidentally, but they are not necessary and can be removed. This is very much an in progress pull request. I'm having an issue with rustfmt. It wanted to reformat the entire file for almost every file by default. And when I run tidy it just errors out because it catches the empty files that are already in the repo. My next step is goin got be to remove those empty file and see if running tidy again will actually reformat things outside of the context of `cargo fmt` Fixes https://github.com/rust-lang/rust/issues/50785
This commit is contained in:
commit
63ea42fd3c
59 changed files with 550 additions and 77 deletions
123
src/test/run-pass/label_break_value.rs
Normal file
123
src/test/run-pass/label_break_value.rs
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(label_break_value)]
|
||||
|
||||
// Test control flow to follow label_break_value semantics
|
||||
fn label_break(a: bool, b: bool) -> u32 {
|
||||
let mut v = 0;
|
||||
'b: {
|
||||
v = 1;
|
||||
if a {
|
||||
break 'b;
|
||||
}
|
||||
v = 2;
|
||||
if b {
|
||||
break 'b;
|
||||
}
|
||||
v = 3;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
// Test that values can be returned
|
||||
fn break_value(a: bool, b: bool) -> u32 {
|
||||
let result = 'block: {
|
||||
if a { break 'block 1; }
|
||||
if b { break 'block 2; }
|
||||
3
|
||||
};
|
||||
result
|
||||
}
|
||||
|
||||
// Test nesting of labeled blocks
|
||||
// here we only check that it compiles
|
||||
fn label_break_nested() {
|
||||
'b: {
|
||||
println!("hi");
|
||||
if false {
|
||||
break 'b;
|
||||
}
|
||||
'c: {
|
||||
if false {
|
||||
break 'b;
|
||||
}
|
||||
break 'c;
|
||||
}
|
||||
println!("hello");
|
||||
if true {
|
||||
break 'b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tests for mixing labeled blocks with loop constructs
|
||||
// This function should be the identity function
|
||||
fn label_break_mixed(v: u32) -> u32 {
|
||||
let mut r = 0;
|
||||
'b: {
|
||||
// Unlabeled break still works
|
||||
// (only crossing boundaries is an error)
|
||||
loop {
|
||||
break;
|
||||
}
|
||||
if v == 0 {
|
||||
break 'b;
|
||||
}
|
||||
// Labeled breaking an inner loop still works
|
||||
'c: loop {
|
||||
if r == 1 {
|
||||
break 'c;
|
||||
}
|
||||
r += 1;
|
||||
}
|
||||
assert_eq!(r, 1);
|
||||
if v == 1 {
|
||||
break 'b;
|
||||
}
|
||||
// Labeled breaking an outer loop still works
|
||||
'd: loop {
|
||||
'e: {
|
||||
if v == r {
|
||||
break 'b;
|
||||
}
|
||||
if r == 5 {
|
||||
break 'd;
|
||||
}
|
||||
r += 1;
|
||||
}
|
||||
}
|
||||
assert_eq!(r, 5);
|
||||
assert!(v > r);
|
||||
// Here we test return from inside a labeled block
|
||||
return v;
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(label_break(true, false), 1);
|
||||
assert_eq!(label_break(false, true), 2);
|
||||
assert_eq!(label_break(false, false), 3);
|
||||
|
||||
assert_eq!(break_value(true, false), 1);
|
||||
assert_eq!(break_value(false, true), 2);
|
||||
assert_eq!(break_value(false, false), 3);
|
||||
|
||||
assert_eq!(label_break_mixed(0), 0);
|
||||
assert_eq!(label_break_mixed(1), 1);
|
||||
assert_eq!(label_break_mixed(2), 2);
|
||||
assert_eq!(label_break_mixed(3), 3);
|
||||
assert_eq!(label_break_mixed(4), 4);
|
||||
assert_eq!(label_break_mixed(5), 5);
|
||||
assert_eq!(label_break_mixed(6), 6);
|
||||
|
||||
// FIXME: ensure that labeled blocks work if produced by macros and in match arms
|
||||
}
|
||||
15
src/test/ui/feature-gate-label_break_value.rs
Normal file
15
src/test/ui/feature-gate-label_break_value.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
'a: { //~ ERROR labels on blocks are unstable
|
||||
break 'a;
|
||||
}
|
||||
}
|
||||
11
src/test/ui/feature-gate-label_break_value.stderr
Normal file
11
src/test/ui/feature-gate-label_break_value.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0658]: labels on blocks are unstable (see issue #48594)
|
||||
--> $DIR/feature-gate-label_break_value.rs:12:5
|
||||
|
|
||||
LL | 'a: { //~ ERROR labels on blocks are unstable
|
||||
| ^^
|
||||
|
|
||||
= help: add #![feature(label_break_value)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
36
src/test/ui/label_break_value_continue.rs
Normal file
36
src/test/ui/label_break_value_continue.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(label_break_value)]
|
||||
|
||||
// Simple continue pointing to an unlabeled break should yield in an error
|
||||
fn continue_simple() {
|
||||
'b: {
|
||||
continue; //~ ERROR unlabeled `continue` inside of a labeled block
|
||||
}
|
||||
}
|
||||
|
||||
// Labeled continue pointing to an unlabeled break should yield in an error
|
||||
fn continue_labeled() {
|
||||
'b: {
|
||||
continue 'b; //~ ERROR `continue` pointing to a labeled block
|
||||
}
|
||||
}
|
||||
|
||||
// Simple continue that would cross a labeled block should yield in an error
|
||||
fn continue_crossing() {
|
||||
loop {
|
||||
'b: {
|
||||
continue; //~ ERROR unlabeled `continue` inside of a labeled block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
30
src/test/ui/label_break_value_continue.stderr
Normal file
30
src/test/ui/label_break_value_continue.stderr
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
error[E0695]: unlabeled `continue` inside of a labeled block
|
||||
--> $DIR/label_break_value_continue.rs:16:9
|
||||
|
|
||||
LL | continue; //~ ERROR unlabeled `continue` inside of a labeled block
|
||||
| ^^^^^^^^ `continue` statements that would diverge to or through a labeled block need to bear a label
|
||||
|
||||
error[E0696]: `continue` pointing to a labeled block
|
||||
--> $DIR/label_break_value_continue.rs:23:9
|
||||
|
|
||||
LL | continue 'b; //~ ERROR `continue` pointing to a labeled block
|
||||
| ^^^^^^^^^^^ labeled blocks cannot be `continue`'d
|
||||
|
|
||||
note: labeled block the continue points to
|
||||
--> $DIR/label_break_value_continue.rs:22:5
|
||||
|
|
||||
LL | / 'b: {
|
||||
LL | | continue 'b; //~ ERROR `continue` pointing to a labeled block
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error[E0695]: unlabeled `continue` inside of a labeled block
|
||||
--> $DIR/label_break_value_continue.rs:31:13
|
||||
|
|
||||
LL | continue; //~ ERROR unlabeled `continue` inside of a labeled block
|
||||
| ^^^^^^^^ `continue` statements that would diverge to or through a labeled block need to bear a label
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0695, E0696.
|
||||
For more information about an error, try `rustc --explain E0695`.
|
||||
31
src/test/ui/label_break_value_illegal_uses.rs
Normal file
31
src/test/ui/label_break_value_illegal_uses.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(label_break_value)]
|
||||
|
||||
// These are forbidden occurences of label-break-value
|
||||
|
||||
fn labeled_unsafe() {
|
||||
unsafe 'b: {} //~ ERROR expected one of `extern`, `fn`, or `{`
|
||||
}
|
||||
|
||||
fn labeled_if() {
|
||||
if true 'b: {} //~ ERROR expected `{`, found `'b`
|
||||
}
|
||||
|
||||
fn labeled_else() {
|
||||
if true {} else 'b: {} //~ ERROR expected `{`, found `'b`
|
||||
}
|
||||
|
||||
fn labeled_match() {
|
||||
match false 'b: {} //~ ERROR expected one of `.`, `?`, `{`, or an operator
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
31
src/test/ui/label_break_value_illegal_uses.stderr
Normal file
31
src/test/ui/label_break_value_illegal_uses.stderr
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
error: expected one of `extern`, `fn`, or `{`, found `'b`
|
||||
--> $DIR/label_break_value_illegal_uses.rs:16:12
|
||||
|
|
||||
LL | unsafe 'b: {} //~ ERROR expected one of `extern`, `fn`, or `{`
|
||||
| ^^ expected one of `extern`, `fn`, or `{` here
|
||||
|
||||
error: expected `{`, found `'b`
|
||||
--> $DIR/label_break_value_illegal_uses.rs:20:13
|
||||
|
|
||||
LL | if true 'b: {} //~ ERROR expected `{`, found `'b`
|
||||
| -- ^^----
|
||||
| | |
|
||||
| | help: try placing this code inside a block: `{ 'b: { } }`
|
||||
| this `if` statement has a condition, but no block
|
||||
|
||||
error: expected `{`, found `'b`
|
||||
--> $DIR/label_break_value_illegal_uses.rs:24:21
|
||||
|
|
||||
LL | if true {} else 'b: {} //~ ERROR expected `{`, found `'b`
|
||||
| ^^----
|
||||
| |
|
||||
| help: try placing this code inside a block: `{ 'b: { } }`
|
||||
|
||||
error: expected one of `.`, `?`, `{`, or an operator, found `'b`
|
||||
--> $DIR/label_break_value_illegal_uses.rs:28:17
|
||||
|
|
||||
LL | match false 'b: {} //~ ERROR expected one of `.`, `?`, `{`, or an operator
|
||||
| ^^ expected one of `.`, `?`, `{`, or an operator here
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
29
src/test/ui/label_break_value_unlabeled_break.rs
Normal file
29
src/test/ui/label_break_value_unlabeled_break.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(label_break_value)]
|
||||
|
||||
// Simple unlabeled break should yield in an error
|
||||
fn unlabeled_break_simple() {
|
||||
'b: {
|
||||
break; //~ ERROR unlabeled `break` inside of a labeled block
|
||||
}
|
||||
}
|
||||
|
||||
// Unlabeled break that would cross a labeled block should yield in an error
|
||||
fn unlabeled_break_crossing() {
|
||||
loop {
|
||||
'b: {
|
||||
break; //~ ERROR unlabeled `break` inside of a labeled block
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
15
src/test/ui/label_break_value_unlabeled_break.stderr
Normal file
15
src/test/ui/label_break_value_unlabeled_break.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
error[E0695]: unlabeled `break` inside of a labeled block
|
||||
--> $DIR/label_break_value_unlabeled_break.rs:16:9
|
||||
|
|
||||
LL | break; //~ ERROR unlabeled `break` inside of a labeled block
|
||||
| ^^^^^ `break` statements that would diverge to or through a labeled block need to bear a label
|
||||
|
||||
error[E0695]: unlabeled `break` inside of a labeled block
|
||||
--> $DIR/label_break_value_unlabeled_break.rs:24:13
|
||||
|
|
||||
LL | break; //~ ERROR unlabeled `break` inside of a labeled block
|
||||
| ^^^^^ `break` statements that would diverge to or through a labeled block need to bear a label
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0695`.
|
||||
|
|
@ -2,7 +2,7 @@ error[E0571]: `break` with value from a `for` loop
|
|||
--> $DIR/loop-break-value-no-repeat.rs:22:9
|
||||
|
|
||||
LL | break 22 //~ ERROR `break` with value from a `for` loop
|
||||
| ^^^^^^^^ can only break with a value inside `loop`
|
||||
| ^^^^^^^^ can only break with a value inside `loop` or breakable block
|
||||
help: instead, use `break` on its own without a value inside this `for` loop
|
||||
|
|
||||
LL | break //~ ERROR `break` with value from a `for` loop
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue