Skip to content

Commit 5118dd5

Browse files
committed
Start block is not allowed to have basic block predecessors
1 parent 8e398f5 commit 5118dd5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::mir::visit::{PlaceContext, Visitor};
99
use rustc_middle::mir::{
1010
AggregateKind, BasicBlock, Body, BorrowKind, Local, Location, MirPhase, Operand, PlaceElem,
1111
PlaceRef, ProjectionElem, Rvalue, SourceScope, Statement, StatementKind, Terminator,
12-
TerminatorKind,
12+
TerminatorKind, START_BLOCK,
1313
};
1414
use rustc_middle::ty::fold::BottomUpFolder;
1515
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeFoldable};
@@ -130,6 +130,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
130130
}
131131

132132
fn check_edge(&self, location: Location, bb: BasicBlock, edge_kind: EdgeKind) {
133+
if bb == START_BLOCK {
134+
self.fail(location, "start block must not have predecessors")
135+
}
133136
if let Some(bb) = self.body.basic_blocks().get(bb) {
134137
let src = self.body.basic_blocks().get(location.block).unwrap();
135138
match (src.is_cleanup, bb.is_cleanup, edge_kind) {

0 commit comments

Comments
 (0)