Skip to content

Commit 7a73783

Browse files
committed
clarify an unreachable branch
1 parent ddd6e6f commit 7a73783

File tree

1 file changed

+10
-7
lines changed
  • compiler/rustc_mir_build/src/builder

1 file changed

+10
-7
lines changed

compiler/rustc_mir_build/src/builder/scope.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
750750
(break_index, None)
751751
}
752752
BreakableTarget::ConstContinue(scope) => {
753-
assert!(value.is_some());
753+
let Some(value) = value else {
754+
span_bug!(span, "#[const_continue] must break with a value")
755+
};
756+
757+
// A break can only break out of a scope, so the value should be a scope
758+
let rustc_middle::thir::ExprKind::Scope { value, .. } = self.thir[value].kind
759+
else {
760+
span_bug!(span, "break value must be a scope")
761+
};
762+
754763
let break_index = self
755764
.scopes
756765
.const_continuable_scopes
@@ -762,12 +771,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
762771
span_bug!(span, "no enclosing const-continuable scope found")
763772
});
764773

765-
let rustc_middle::thir::ExprKind::Scope { value, .. } =
766-
self.thir[value.unwrap()].kind
767-
else {
768-
panic!();
769-
};
770-
771774
let scope = &self.scopes.const_continuable_scopes[break_index];
772775

773776
let state_ty = self.local_decls[scope.state_place.as_local().unwrap()].ty;

0 commit comments

Comments
 (0)