Skip to content

Commit 46d6915

Browse files
Add continue livenodes in liveness check for blocks
1 parent 53ed660 commit 46d6915

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed

compiler/rustc_passes/src/liveness.rs

+1
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
759759
fn propagate_through_block(&mut self, blk: &hir::Block<'_>, succ: LiveNode) -> LiveNode {
760760
if blk.targeted_by_break {
761761
self.break_ln.insert(blk.hir_id, succ);
762+
self.cont_ln.insert(blk.hir_id, succ);
762763
}
763764
let succ = self.propagate_through_opt_expr(blk.expr, succ);
764765
blk.stmts.iter().rev().fold(succ, |succ, stmt| self.propagate_through_stmt(stmt, succ))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#![allow(incomplete_features)]
2+
#![feature(adt_const_params)]
3+
4+
trait Trait<const S: &'static str> {}
5+
6+
struct Bug<T>
7+
where
8+
T: Trait<
9+
{
10+
'b: {
11+
continue 'b;
12+
//~^ ERROR [E0080]
13+
//~| ERROR [E0080]
14+
//~| ERROR [E0696]
15+
}
16+
},
17+
>,
18+
{
19+
t: T,
20+
}
21+
22+
fn f() -> impl Sized {
23+
'b: {
24+
continue 'b;
25+
//~^ ERROR [E0696]
26+
}
27+
}
28+
29+
fn main() {
30+
f();
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
error[E0696]: `continue` pointing to a labeled block
2+
--> $DIR/cont-in-fn-issue-113379.rs:11:17
3+
|
4+
LL | / 'b: {
5+
LL | | continue 'b;
6+
| | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d
7+
LL | |
8+
LL | |
9+
LL | |
10+
LL | | }
11+
| |_____________- labeled block the `continue` points to
12+
13+
error[E0696]: `continue` pointing to a labeled block
14+
--> $DIR/cont-in-fn-issue-113379.rs:24:9
15+
|
16+
LL | / 'b: {
17+
LL | | continue 'b;
18+
| | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d
19+
LL | |
20+
LL | | }
21+
| |_____- labeled block the `continue` points to
22+
23+
error[E0080]: evaluation of constant value failed
24+
--> $DIR/cont-in-fn-issue-113379.rs:11:17
25+
|
26+
LL | continue 'b;
27+
| ^^^^^^^^^^^ entering unreachable code
28+
29+
error[E0080]: evaluation of constant value failed
30+
--> $DIR/cont-in-fn-issue-113379.rs:11:17
31+
|
32+
LL | continue 'b;
33+
| ^^^^^^^^^^^ entering unreachable code
34+
|
35+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
36+
37+
error: aborting due to 4 previous errors
38+
39+
Some errors have detailed explanations: E0080, E0696.
40+
For more information about an error, try `rustc --explain E0080`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
match () {
3+
_ => 'b: {
4+
continue 'b;
5+
//~^ ERROR [E0696]
6+
}
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0696]: `continue` pointing to a labeled block
2+
--> $DIR/cont-in-match-arm-issue-121623.rs:4:13
3+
|
4+
LL | _ => 'b: {
5+
| ______________-
6+
LL | | continue 'b;
7+
| | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d
8+
LL | |
9+
LL | | }
10+
| |_________- labeled block the `continue` points to
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0696`.

0 commit comments

Comments
 (0)