Add tests for control flow in while condition
This commit is contained in:
parent
4d65622dcd
commit
56e519dd5c
55
src/test/compile-fail/issue-37576.rs
Normal file
55
src/test/compile-fail/issue-37576.rs
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright 2012 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.
|
||||
|
||||
fn main() {
|
||||
'test_1: while break 'test_1 {}
|
||||
while break {}
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
|
||||
'test_2: while let true = break 'test_2 {}
|
||||
while let true = break {}
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
|
||||
loop { 'test_3: while break 'test_3 {} }
|
||||
loop { while break {} }
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
|
||||
loop {
|
||||
'test_4: while break 'test_4 {}
|
||||
break;
|
||||
}
|
||||
loop {
|
||||
while break {}
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
break;
|
||||
}
|
||||
|
||||
'test_5: while continue 'test_5 {}
|
||||
while continue {}
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
|
||||
'test_6: while let true = continue 'test_6 {}
|
||||
while let true = continue {}
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
|
||||
loop { 'test_7: while continue 'test_7 {} }
|
||||
loop { while continue {} }
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
|
||||
loop {
|
||||
'test_8: while continue 'test_8 {}
|
||||
continue;
|
||||
}
|
||||
loop {
|
||||
while continue {}
|
||||
//~^ ERROR `break` or `continue` with no label
|
||||
continue;
|
||||
}
|
||||
}
|
@ -17,8 +17,7 @@ fn f() {
|
||||
}
|
||||
}
|
||||
|
||||
// issue #37353
|
||||
loop { 'w: while break 'w { } } //~ ERROR use of undeclared label
|
||||
loop { 'w: while break 'w { } }
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -5,10 +5,10 @@ digraph block {
|
||||
N3[label="local mut x"];
|
||||
N4[label="stmt let mut x = 10;"];
|
||||
N5[label="(dummy_node)"];
|
||||
N6[label="expr x"];
|
||||
N7[label="expr 0"];
|
||||
N8[label="expr x > 0"];
|
||||
N9[label="expr while x > 0 { x -= 1; }"];
|
||||
N6[label="expr while x > 0 { x -= 1; }"];
|
||||
N7[label="expr x"];
|
||||
N8[label="expr 0"];
|
||||
N9[label="expr x > 0"];
|
||||
N10[label="expr 1"];
|
||||
N11[label="expr x"];
|
||||
N12[label="expr x -= 1"];
|
||||
@ -20,17 +20,17 @@ digraph block {
|
||||
N2 -> N3;
|
||||
N3 -> N4;
|
||||
N4 -> N5;
|
||||
N5 -> N6;
|
||||
N6 -> N7;
|
||||
N5 -> N7;
|
||||
N7 -> N8;
|
||||
N8 -> N9;
|
||||
N8 -> N10;
|
||||
N9 -> N6;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N13 -> N14;
|
||||
N14 -> N5;
|
||||
N9 -> N15;
|
||||
N6 -> N15;
|
||||
N15 -> N16;
|
||||
N16 -> N1;
|
||||
}
|
||||
|
@ -11,28 +11,28 @@ digraph block {
|
||||
N9[label="local mut z"];
|
||||
N10[label="stmt let mut z = 23;"];
|
||||
N11[label="(dummy_node)"];
|
||||
N12[label="expr x"];
|
||||
N13[label="expr 0"];
|
||||
N14[label="expr x > 0"];
|
||||
N15[label="expr while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
|
||||
N12[label="expr while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"];
|
||||
N13[label="expr x"];
|
||||
N14[label="expr 0"];
|
||||
N15[label="expr x > 0"];
|
||||
N16[label="expr 1"];
|
||||
N17[label="expr x"];
|
||||
N18[label="expr x -= 1"];
|
||||
N19[label="stmt x -= 1;"];
|
||||
N20[label="(dummy_node)"];
|
||||
N21[label="expr y"];
|
||||
N22[label="expr 0"];
|
||||
N23[label="expr y > 0"];
|
||||
N24[label="expr while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"];
|
||||
N21[label="expr while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"];
|
||||
N22[label="expr y"];
|
||||
N23[label="expr 0"];
|
||||
N24[label="expr y > 0"];
|
||||
N25[label="expr 1"];
|
||||
N26[label="expr y"];
|
||||
N27[label="expr y -= 1"];
|
||||
N28[label="stmt y -= 1;"];
|
||||
N29[label="(dummy_node)"];
|
||||
N30[label="expr z"];
|
||||
N31[label="expr 0"];
|
||||
N32[label="expr z > 0"];
|
||||
N33[label="expr while z > 0 { z -= 1; }"];
|
||||
N30[label="expr while z > 0 { z -= 1; }"];
|
||||
N31[label="expr z"];
|
||||
N32[label="expr 0"];
|
||||
N33[label="expr z > 0"];
|
||||
N34[label="expr 1"];
|
||||
N35[label="expr z"];
|
||||
N36[label="expr z -= 1"];
|
||||
@ -63,35 +63,35 @@ digraph block {
|
||||
N8 -> N9;
|
||||
N9 -> N10;
|
||||
N10 -> N11;
|
||||
N11 -> N12;
|
||||
N12 -> N13;
|
||||
N11 -> N13;
|
||||
N13 -> N14;
|
||||
N14 -> N15;
|
||||
N14 -> N16;
|
||||
N15 -> N12;
|
||||
N15 -> N16;
|
||||
N16 -> N17;
|
||||
N17 -> N18;
|
||||
N18 -> N19;
|
||||
N19 -> N20;
|
||||
N20 -> N21;
|
||||
N21 -> N22;
|
||||
N20 -> N22;
|
||||
N22 -> N23;
|
||||
N23 -> N24;
|
||||
N23 -> N25;
|
||||
N24 -> N21;
|
||||
N24 -> N25;
|
||||
N25 -> N26;
|
||||
N26 -> N27;
|
||||
N27 -> N28;
|
||||
N28 -> N29;
|
||||
N29 -> N30;
|
||||
N30 -> N31;
|
||||
N29 -> N31;
|
||||
N31 -> N32;
|
||||
N32 -> N33;
|
||||
N32 -> N34;
|
||||
N33 -> N30;
|
||||
N33 -> N34;
|
||||
N34 -> N35;
|
||||
N35 -> N36;
|
||||
N36 -> N37;
|
||||
N37 -> N38;
|
||||
N38 -> N29;
|
||||
N33 -> N39;
|
||||
N30 -> N39;
|
||||
N39 -> N40;
|
||||
N40 -> N41;
|
||||
N41 -> N42;
|
||||
@ -105,9 +105,9 @@ digraph block {
|
||||
N48 -> N49;
|
||||
N49 -> N50;
|
||||
N50 -> N20;
|
||||
N24 -> N51;
|
||||
N21 -> N51;
|
||||
N51 -> N11;
|
||||
N15 -> N52;
|
||||
N12 -> N52;
|
||||
N52 -> N53;
|
||||
N53 -> N1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user