Skip to content

Commit 96be62b

Browse files
committed
clarify an unreachable branch
1 parent 22835d5 commit 96be62b

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
@@ -753,7 +753,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
753753
(break_index, None)
754754
}
755755
BreakableTarget::ConstContinue(scope) => {
756-
assert!(value.is_some());
756+
let Some(value) = value else {
757+
span_bug!(span, "#[const_continue] must break with a value")
758+
};
759+
760+
// A break can only break out of a scope, so the value should be a scope
761+
let rustc_middle::thir::ExprKind::Scope { value, .. } = self.thir[value].kind
762+
else {
763+
span_bug!(span, "break value must be a scope")
764+
};
765+
757766
let break_index = self
758767
.scopes
759768
.const_continuable_scopes
@@ -765,12 +774,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
765774
span_bug!(span, "no enclosing const-continuable scope found")
766775
});
767776

768-
let rustc_middle::thir::ExprKind::Scope { value, .. } =
769-
self.thir[value.unwrap()].kind
770-
else {
771-
panic!();
772-
};
773-
774777
let scope = &self.scopes.const_continuable_scopes[break_index];
775778

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

0 commit comments

Comments
 (0)