Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/librustc_passes/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
opt_expr.map_or(succ, |expr| self.propagate_through_expr(expr, succ))
}

fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
-> LiveNode {
fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode {
debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id));

match expr.kind {
Expand Down Expand Up @@ -1074,7 +1073,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {

match target {
Some(b) => self.propagate_through_opt_expr(opt_expr.as_ref().map(|e| &**e), b),
None => span_bug!(expr.span, "break to unknown label")
None => {
// FIXME: This should have been checked earlier. Once this is fixed,
// replace with `delay_span_bug`. (#62480)
self.ir.tcx.sess.struct_span_err(
expr.span,
"`break` to unknown label",
).emit();
errors::FatalError.raise()
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-62480.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![feature(label_break_value)]

fn main() {
// This used to ICE during liveness check because `target_id` passed to
// `propagate_through_expr` would be the closure and not the `loop`, which wouldn't be found in
// `self.break_ln`. (#62480)
'a: {
|| break 'a //~ ERROR `break` to unknown label
}
}
8 changes: 8 additions & 0 deletions src/test/ui/issues/issue-62480.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: `break` to unknown label
--> $DIR/issue-62480.rs:8:12
|
LL | || break 'a
| ^^^^^^^^

error: aborting due to previous error